Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve it in details Instructions: Answer all questions. You may write your answers legibility by hand. Qu 1: The following algorithms are for the

please solve it in details image text in transcribed
Instructions: Answer all questions. You may write your answers legibility by hand. Qu 1: 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 algorithms, find each of the following: (i) 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 constant. (2 Marks) a) //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) //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 return count c) //returns the node containing a given target value or NIL if not found List_Find (L, target) X = L.head while x NIL and x.info target x = x.next return x

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

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

More Books

Students also viewed these Databases questions

Question

2. Do yotl think polilics and

Answered: 1 week ago