Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Q. Develop a representation for a list where insertions and deletions can be done at either end. Such a structure is known as a Deque (Double ended queue). Write functions for inserting and deleting at either of the end.

Ans.

There are number of ways of representing dequeue in a computer. We will suppose that dequeue is maintained by a circular array DEQUE with pointer FRONT and REAR, which point to the 2 ends of dequeue. We suppose that the element extend from the left end to the right end in the array. The condition FRONT = NULL will be used to indicate that dequeue is blank.

Algorithm for inserting in dequeue is written below

Step 1:  [check overflow condition] If rear ≥  n and front = 0

Output :overflow and return"

Step 2:  [check front pointer value] If front > 0

Front = front -1

Else

Return

Step 3:  [insert element at the front end] Q[front ] = value

Step 4:  [check rear pointer value] If rear < n

Rear = rear +1

Else

Return

Step 5:  [insert element at the rear end] Q [rear] = value

Step 6:  Return

Deletion Algorithm for dequeue is given below

Step 1:  [check for underflow] If front = 0 and rear = 0

Output "underflow" and return

Step 2:  [delete element at front end] If front > 0

Value = q [front] Return [value]

Step 3:  [check queue for empty]

If front = rear

Front = rear = 0

Else

Front = front +1

Step 4:  [delete element at the rear end] If rear > 0

Value = Q [rear] Return (rear)

Step 5:  [check queue for empty] If front = rear

Front = rear = 0

Else

Rear = rear - 1

Step 6:   Return

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9504401

Have any Question?


Related Questions in Computer Engineering

Question suppose we have a packet switched network in which

Question : Suppose we have a packet switched network in which two stations A and B are always separated by four intermediate nodes/switches, i.e., the two are 5 hops apart. Suppose station A wishes to transmit 1 MB (1024 ...

Round robin rr jobs are processed using a fixed time-slice

Round Robin (RR): Jobs are processed using a fixed time-slice. The jobs are initially kept in a queue based on the order of arrival. The job at the front of the queue is removed and served similar to the FIFO algorithm. ...

Question suppose that a bayesian spam filter is trained on

Question : Suppose that a Bayesian spam filter is trained on a set of 10000 spam messages and 5000 messages that are not spam. The word "opportunity" appears in 175 spam messages and 20 messages that are not spam. Would ...

Why is it important to back up the dhcp database and

Why is it important to back up the DHCP database and Identify key files that make up the DHCP database?

Alpine company stock is selling for 3240 a share one 30

Alpine Company stock is selling for $32.40 a share. One $30 call is valued at $2.76 and one $29 put is valued at $.65. What is the value of three call option contracts (remember that one contract includes 100 options)?

This chart lists the estimated lengths and arrival times

This chart lists the estimated lengths and arrival times for 5 jobs. In what order do these run using FCFS? What is the average turn-around time (difference in time between a job's arrival and its completion)? In what or ...

Examine the us passenger airline industry using the five

Examine the U.S. passenger airline industry using the five forces. Is this an attractive industry? Why or why not?

Question is it ethical for a potential employer to use the

Question: Is it ethical for a potential employer to use the Internet this way? Is it legal? What if an angry ex-boyfriend or ex-girlfriend posted some things, pretending to be you? How might this affect your chances for ...

A study investigated whether time perception an indication

A study investigated whether time perception, an indication of a person's ability to concentrate, is impaired during nicotine withdrawal. Smokers were randomly selected and asked to estimate how much time has passed duri ...

Small business e-commerce portals check out small business

Small Business e-Commerce Portals Check out Small Business Center and the other e-commerce portals mentioned. Then answer the questions. Note: Small Business Center and Entrabase.com are interesting sites that offer a wi ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As