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);
include include include /* Definition of structure node */ typedef struct node { int data; struct node *next; } ; /* Definition of push function */
Explain an efficient way of storing a sparse matrix in memory. A matrix in which number of zero entries are much higher than the number of non zero entries is called sparse mat
Define Prim's Algorithm Prim's algorithm is a greedy algorithm for constructing a minimum spanning tree of a weighted linked graph. It works by attaching to a bef
#question.explain different types of errors in data transmission.
Q. How do we represent a max-heap sequentially? Explain by taking a valid example. Ans: A max heap is also called as a descending heap, of size n is an almos
One of the best known methods for external sorting on tapes is the polyphase sort. Principle: The basic strategy of this sort is to distribute ordered initial runs of predetermi
What is Space complexity of an algorithm? Explain.
bfs and dfs
A representation of an array structure is a mapping of the (abstract) array with elements of type T onto the store which is an array with elements of type BYTE. The array could be
What are stored and derived attributes? Stored attributes: The attributes kept in a data base are called stored attributes. Derived attributes: The attributes that are
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