简体   繁体   中英

Total insertion and deletion time

The Professor: your program needs to print total insertion time and total deletion time for all the insertion and deletion scenarios.

We need to use it in a Circular singly and Doubly linked list. I was wondering how I can find the time!!! Thanks

This is my output.

Adding node 100 at start Adding node 1000 at start Adding node 10000 at start Adding node 100000 at start Circular Linked List: <-> 100000 <-> 10000 <-> 1000 <-> 100

deleting node 100000 from start Circular Linked List: <-> 10000 <-> 1000 <-> 100

Node 100000 is added at the end of the list Circular Linked List: <-> 10000 <-> 1000 <-> 100 <-> 100000 Size of linked list: 4 Element at 2nd position: 1000

You need to record time at start and end of the operation. Difference between end time and start time is the time taken by the operation.

At operation start:

start_time = current_time

At operation end:

end_time = current_time
exec_time = end_time - start_time

Use appropriate time api based on programming language being used.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM