Data Structures: Lists and Stacks, Quizzes of Computer Science

Definitions and comparisons of various list and stack data structures, including array-based list, linked list, single linked list, dynamic array, freelists, doubly linked lists, and stack implementations. It covers concepts such as length, head, tail, convenience methods, overhead, and time comparison.

Typology: Quizzes

2013/2014

Uploaded on 01/28/2014

ckingry5
ckingry5 🇺🇸

21 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
TERM 1
List
Definition
DEFINITION 1
A finite ordered sequence of elements, similar to
mathematical sequence. Ordered simply means that an
element has a given position in the list not that the list is
sorted.
TERM 2
Length
DEFINITION 2
Number of elements currently stored
TERM 3
head
DEFINITION 3
beginning node to list
TERM 4
tail
DEFINITION 4
End or last element of the list.
TERM 5
Convenience Method
DEFINITION 5
A method that is implemented by means of other member
functions in the same asymptotic time.
pf3
pf4
pf5

Partial preview of the text

Download Data Structures: Lists and Stacks and more Quizzes Computer Science in PDF only on Docsity!

List

Definition

A finite ordered sequence of elements, similar to mathematical sequence. Ordered simply means that an element has a given position in the list not that the list is sorted. TERM 2

Length

DEFINITION 2 Number of elements currently stored TERM 3

head

DEFINITION 3 beginning node to list TERM 4

tail

DEFINITION 4 End or last element of the list. TERM 5

Convenience Method

DEFINITION 5 A method that is implemented by means of other member functions in the same asymptotic time.

Array based List O

Get value at element - O(1)Insert - O(n) in average caseAppendRemove - O(n) in average case TERM 7

Linked List

DEFINITION 7 requires dynamic memory allocation for each node TERM 8

List Node

DEFINITION 8 Requires a field for the object stored and a pointer to the next node, and for a doubly-linked list a pointer to the previous node. Or instead of using pointers you could have theactual nodes as fields. TERM 9

Single Linked List O

DEFINITION 9 Insert - O(1)Insert to i position - O(n) on averageremove - O(1)Remove element at position i - O(n) on average caseGet position i - O(i), O(n) on averageNext - O(1)Previous - O(n - i - 1), O(n) on average TERM 10

Overhead

DEFINITION 10 Additional memory space required by a structure for data to be organized or stored. Array has overhead when using it to implement the List structure because the size of the array must be allocated for the elements to be entered. The LList has overhead because it needs the next pointer field.

homogeneity

All objects stored in a structure are of the same type TERM 17

Stack

DEFINITION 17 list structure where objects are inserted and removed only from one end and works in LIFO (Last in first out). The accessible element is the top, where objects are pushed on and popped off. TERM 18

Array Stack

DEFINITION 18 Have the "top" of the stack be the end (position n-1), for their implementation they used the top at position n so it was the first empty element on the stack.This has the same draw backs as the array list implementation except the shifting of elements to maintain contiguous memory space. TERM 19

Linked Stack

DEFINITION 19 An example is the freelist, elements are inserted and removed only at the end just like the array implementation. This does not require a head sentry node, the first element or the head of the linked list is the top of the stack. TERM 20

Array vs Link implem. of Stack

DEFINITION 20 Neither is more time efficient, but you still have the overhead problem with both so you would analyze the situation similar to with a list, but the array provides an interesting implementation of two stacks that grow inversely where you can start the stacks at opposite ends of the array growing inwards towards eachother.

Activation record

Information pushed onto the stack for subroutine calls. TERM 22

Towers of Hanoi recursion example

DEFINITION 22 hmmmmmm, well then.Apparently because calling a function recursively is relatively expensive it is better to use iteration, but that makes ugly code (supposedly but I think recursion is difficult to understand when reading someone else's code) and sometimes it cannot be done using iteration.....although i thought it could, but apparently not. TERM 23

Queue

DEFINITION 23 list like structure, insertion occurs at the back called enqueue and removed from the front called dequeue, like a lunch line. A queue is a FIFO list unlike the stack which is a LIFO. TERM 24

Array Queue

DEFINITION 24 The implementation is tricky there are weird special cases. This is handled by letting the front and rear elements change position with the data instead of being fixed to the front of the array. You treat the array like a circle where the highest element connects to the lowest, you use mod operator