Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Q. Perform implementation of a queue using a singly linked list L. The operations INSER and DELETE should take O (1) time.
Ans:
Implementation of queue by using a singly linked list: When implement a queue as a single liked list, a queue q consists of a list and two pointers, q.front and the q.rear. inserting an element is stated below: insert(q,x) { p=getnode(); info(p) = x; next(p) = null; if(q.rear == null) q.front = p; else next(q.rear) = p; q.rear = p; } deletion is stated below: remove(q) { if(empty(q)) { printf("queue overflow"); exit(1); } p=q.front; x=info(p); q.front=next(p); if(q.front == null) q.rear = null; freenode(p); return(x); }
Implementation of queue by using a singly linked list:
When implement a queue as a single liked list, a queue q consists of a list and two pointers, q.front and the q.rear.
inserting an element is stated below:
insert(q,x)
{
p=getnode(); info(p) = x; next(p) = null; if(q.rear == null)
q.front = p;
else
next(q.rear) = p;
q.rear = p;
}
deletion is stated below:
remove(q)
if(empty(q))
printf("queue overflow");
exit(1);
p=q.front; x=info(p); q.front=next(p); if(q.front == null) q.rear = null; freenode(p); return(x);
What is an Algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for getting a needed output for any legitimate input in a finite amoun
What do you understand by tree traversal? The algorithm walks by the tree data structure and performs some computation at everynode in the tree. This process of walking by the
Explain Division Method Division Method: - In this method, key K to be mapped into single of the m states in the hash table is divided by m and the remainder of this division
5. Implement a stack (write pseudo-code for STACK-EMPTY, PUSH, and POP) using a singly linked list L. The operations PUSH and POP should still take O(1) time.
A queue is a, FIFO (First In First Out) list.
Krushkal's algorithm uses the concept of forest of trees. At first the forest contains n single node trees (and no edges). At each of the step, we add on one (the cheapest one) edg
Any binary search tree must contain following properties to be called as a red-black tree. 1. Each node of a tree should be either red or black. 2. The root node is always bl
Q. Write down the algorithm for binary search. Which are the conditions under which sequential search of a list is preferred over the binary search?
Q. The degree of a node is defined as the number of children it has. Shear show that in any binary tree, the total number of leaves is one more than the number of nodes of degree 2
null(nil) = true // nil refer for empty tree null(fork(e, T, T'))= false // e : element , T and T are two sub tree leaf(fork(e, nil, nil)) = true leaf(
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +91-977-207-8620
Phone: +91-977-207-8620
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd