Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

design and analysis of algorithms the Question has 3 parts. please solve it Q1: The following algorithms are for the operations of a doubly linked

design and analysis of algorithms
the Question has 3 parts. please solve it
image text in transcribed
image text in transcribed
Q1: The following algorithms are for the operations of a doubly linked list, L. It is assumed that the list has 2 attributes, head and tail referencing the first and last node respectively. A node of the list is assumed to have 3 attributes, info, next and prev referencing the data item in the node, the next node and previous node respectively. For each of the following algorithms, find 1. The general running time function, T(n), where n is the number of elements in the list. II. The worst-case running time. III. The classification of the running time in notation. You may assume that the running of all basic operations, including that of creating a node object is (2 Marks) constant. //adds a node containing the data value, v, at the end of the list List_AddToTail(L, V) x = new List_Node(v) if L.IsEmpty x.next = x.prev - NIL L.head = L.tail = x else x.next = NIL X.prev = tail L.tail = L.tail.next = x b) 1/returns the size (i.e. count of nodes) in the list List_Size(L) count=0 X = L.head while x * NIL count = count + 1 XX.next return count //returns the node containing a given target value or NIL if not found List_FindL, target) XL head while XNIL and X.info target XX.next retum

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

2. Identify issues/causes for the apparent conflict.

Answered: 1 week ago