| |

VerySource

 Forgot password?
 Register
Search
View: 694|Reply: 2

If only the head pointer is set, how long does it take to enter or dequeue? ? ?

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-15 22:30:01
| Show all posts |Read mode
Let a chain queue of length n be represented by a single-loop linked list
If only the head pointer is set, how long does it take to enter or dequeue? ? ?
What if we only set the tail pointer? ?
How much time does it take
Reply

Use magic Report

0

Threads

8

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-6-17 14:15:01
| Show all posts
The characteristics of the queue are: first-in first-out;
The characteristics of the single chain are: when iterating, you can only move forward, not turn back;
In the case where only the head pointer is known:
Into the pair: first traverse the single chain, find the tail pointer, time complexity O (n);
Out of right: just directly access the head pointer, time complexity O(1);
Only know that the situation of the tail pointer is the opposite of the analysis above.
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 Invalid IP Address

 Author| Post time: 2020-6-19 15:30:02
| Show all posts
Thank you
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list