Data Structures & Algorithms Exam Linked Lists

¡Supera tus tareas y exámenes ahora con Quizwiz!

difference between -> and .

In C++, you use . when you're dealing with variables. You use -> when you are dealing with pointers.

Array vs. Linked List : Dependency

In array, each element is independent, no connection with previous element or with its location. In Linked list, location or address of elements is stored in the link part of previous element/node.

Array vs. Linked List Memory Structure

In array, elements are stored in consecutive manner in memory. In linked list, elements can be stored at any available place as address of node is stored in previous node.

Array vs. Linked List: Memory Structure

In array, elements are stored in consecutive manner in memory. In linked list, elements can be stored at any available place as address of node is stored in previous node.

Array vs. Linked List Access

In array, elements can be accessed using index/subscript value, i.e. elements can be randomly accessed like arr[0], arr[3], etc. So array provides fast and random access and accessing element takes O(1) time. In linked list, elements can't be accessed randomly but can be accessed only sequentially and accessing element takes O(n) time.

Array vs. Linked List Memory Allocation

In array, memory is allocated at compile time i.e. Static Memory Allocation. In linked list, memory is allocated at run time i.e. Dynamic Memory Allocation.

Array vs. Linked List Extra Space

In array, no pointers are used like linked list so no need of extra space in memory for pointer. In linked list, adjacency between the elements are maintained using pointers or links, so pointers are used and for that extra memory space is needed.

Linked list '.' vs. '->'

In our LinkedList class, we use pointers to a node object, therefore we use -> operator. (i.e. head is a pointer to node object, we use (head->next) to access "next" member in node struct ).

Array vs. Linked List Insertion and Deletion

Insertion & deletion takes more time in array as elements are stored in consecutive memory locations. Insertion & deletion are fast & easy in linked list as only value of pointer is needed to change.

Dope vector

When an array is created, a special data structure is used to store some information related to this array. This data structure is called dope vector. The dope vector stores the address of the first element in the array, array size, and array type. Dope vectors help compilers to access any element of the arrays directly "random access".

read: x->y

member y of object pointed to by x

read: x.y

member y of object x

read: *x

pointed to by x

Array vs. Linked List ( Types)

Array can be single dimensional, two dimension or multidimensional. Linked list can be singly, doubly or circular linked list.

Array vs. Linked list definition

Array is a collection of elements having same data type with common name. Linked list is an ordered collection of elements which are connected by links/pointers.

read: &x

address of x


Conjuntos de estudio relacionados

Biology Final 1st semester Review

View Set

Logical Fallacy Quiz-Public Speaking

View Set

Global Relations Unit 7 The United Nations and Human Rights

View Set

Paris Peace Conference and Treaty of Versailles

View Set