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);
Q. A Binary tree comprises 9 nodes. The preorder and inorder traversals of the tree yield the given sequence of nodes: Inorder : E A C K F H D
i want to write code for unification algorithm with for pattern matching between two expression with out representing an expression as alist
Circular Queues:- A more efficient queue representation is get by regarding the array Q(1:n) as circular. It becomes more convenient to declare the array as Q(O: n-1), when re
If a node in a binary tree is not containing left or right child or it is a leaf node then that absence of child node can be represented by the null pointers. The space engaged by
Write an algorithm for getting solution to the Tower's of Hanoi problem. Explain the working of your algorithm (with 4 disks) with appropriate diagrams. Ans: void Hanoi(int
Determine the number of character comparisons made by the brute-force algorithm in searching for the pattern GANDHI in the text
What is the difference between a grounded header link list and a circular header link list? A header linked list is a linked list which always having a special node, known as t
Warnock's Algorithm An interesting approach to the hidden-surface problem was presented by Warnock. His method does not try to decide exactly what is happening in the scene but
Question 1. How can you find out the end of a String? Write an algorithm to find out the substring of a string. 2. Explain the insertion and deletion operation of linked lis
In a circular linked list There is no beginning and no end.
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: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd