Docsity

Final | CS 2114 - Softw Des & Data Structures, Quizzes of Computer Science

Toggle sidebar
bg1
TERM 1
Stack
DEFINITION 1
push - put stuff inpop - take off of stacktop/peek - see the
object on the top of the stack"LIFO" - last in first out, refers to
the ordering in the stackwhen an object is added to the stack
it is added to the top, and when an object is removed it is
removed from the top. Can be implemented using the
arraylist or a linked list.
TERM 2
Linked List
DEFINITION 2
join - requires the link to be split prior and links the object to
the next then returns the object you called it on.split - sets
the the link to null, and returns the object it was linked to.You
can use sentinels to avoid special cases, when adding and
removing links.
TERM 3
Double Linked
list
DEFINITION 3
Same as the linked list except joined in both directions;
therefore you can go through the list in either direction.With
these and the single linked list you can do a tail share.
TERM 4
Que
DEFINITION 4
This is basically a circular array. You enqueue on one end and
dequeue on the other. They both have efficiency of 1.when
adding or removing an objectback = (back+1)%lengthfront
= (front + 1)%length
TERM 5
Deque
DEFINITION 5
Double ended que you can add and remove from both sides.
pf3
pf4

Partial preview of the text

Download Final | CS 2114 - Softw Des & Data Structures and more Quizzes Computer Science in PDF only on Docsity!

Stack

push - put stuff inpop - take off of stacktop/peek - see the object on the top of the stack"LIFO" - last in first out, refers to the ordering in the stackwhen an object is added to the stack it is added to the top, and when an object is removed it is removed from the top. Can be implemented using the arraylist or a linked list. TERM 2

Linked List

DEFINITION 2 join - requires the link to be split prior and links the object to the next then returns the object you called it on.split - sets the the link to null, and returns the object it was linked to.You can use sentinels to avoid special cases, when adding and removing links. TERM 3

Double Linked

list

DEFINITION 3 Same as the linked list except joined in both directions; therefore you can go through the list in either direction.With these and the single linked list you can do a tail share. TERM 4

Que

DEFINITION 4 This is basically a circular array. You enqueue on one end and dequeue on the other. They both have efficiency of 1.when adding or removing an objectback = (back+1)%lengthfront = (front + 1)%length TERM 5

Deque

DEFINITION 5 Double ended que you can add and remove from both sides.

Array vs. Link

We use arrays over links because all the data is stored in the same place, unlike a linked list where it can be stored pretty much anywhere.Links however you can do a tail share. TERM 7

Copying stuff from an array

DEFINITION 7 System.arraycopy(contents, front, newcontents, 0, size)this was called for creating a new larger buffer. TERM 8

Binary Tree

DEFINITION 8 height - full length of the tree to the furthest leaf based on counting from 1.depth - distance to a node start counting from 0.Recognized relations parent, child, sibling.root is the top, leaf are the nodes without childrenn = 2^h is the relation between leaves and height TERM 9

Removing from a Binary Search tree

DEFINITION 9 to remove a node without children, just disconnect the leaf. With just one child then disconnect between the parent node and child then the child's child then connect the parent to the "grandchild".If the node has two children then replace it with the right most child on the left side, or the left most child on the right side. TERM 10

In-Order traversal

DEFINITION 10 reads left child- parent - right child

Iterator

used for easily iterating through a collection.supports hasNext() - checks for the next objectnext() - returns current and moves to nextand remove() - removes a random objectnot wanted for tree, stack or que.This method is required when a class implements iterable,either it returns the object which is the iterator, whether it is a nested class which implements iterator, or the iterator defined for the class already such as for an array. TERM 17

Iterable

DEFINITION 17 implemented by a class you wish to use it's iterartor. TERM 18

Using iterator

DEFINITION 18 when using the iterator next returns the last object not the current so you don't see the object until it is passed so remove removes the last object etc. TERM 19

Big O in order

DEFINITION 19 1 constantlogn cuts data in halfn linear for loopnlogn log linearn^2 quadraticn^3...... cubic2^n exponentialn! factorialn^n infinite shuffling by throwing in the air