CIS 252 Introduction to Data Structures - C++

Ace your homework & exams now with Quizwiz!

What is true about an ADT TREE ( This is a multi answer questions - check all that are true )

- A tree is a recursive data structure - A tree can be broken up into sub trees - A node in a tree that has no children is called a leaf - A tree can have a root node

First level abstractions are...

- Are commonly accomplished by children - Founded on the physical world and perceptions - Cat, dog, fish, ball

Perception is...

- Automatic integrations of your sensations into one easy to comprehend smell, touch, taste, sight or sound - Effectively the basis of all knowledge

Who uses C++?

- CIS 250 - SpaceX and Elon Musk

Other terms for 'concept' are:

- Class - Mental Entity - Word - Idea

What do these 4 lines of code do ? // comment each line vector <int> myIntVector ( 20, 0 ); vector::interator it; it = myIntVector.begin() + 1; myIntVector.insert(it, 11);

- Create a vector named 'myIntVector' that has an initial size of 20 elements all set to 0 - creating an iterator - setting iterator at the beginning of the vector holding a position in the vector - inserting value 11 at the beginning, the position that the iterator is holding

What is data cleansing

- Inspecting data after it is sorted

Creating 'Concepts from Concepts' (This is a multi answer question - select ALL that are correct)

- Is a volitional mental process - Requires defining characteristics common to all the base concepts subsummed by the new concept

Big O is...

- Measuring the worst case of data quantity - Look at the performance of an algorithm as the quantity of data increases - Is concerned with the amount of RAM used

It is common to implement a queue with...(This is a multi answer question - check all that apply)

- Open two direction linked lists - Circular arrays

What is overflow Select all that can be true... (This is a multi answer question - check all that apply)

- Reached maximum physical size - array implementation - Reached maximum logical size - pointer implementation

The crow is the...

- Recognition that a mind can only hold a limited number of things in focus at once - The biological/physical basis for the need to create concepts - Is something you can observe in yourself

When you try to add data to a stack and there is no more room.. ( This is a multiple answer question - check all that apply )

- You are experiencing stack overflow - It is probably implemented with an array

The position, top of the stack, is..... ( This is a multiple answer questions - check all that apply )

- is where you add data to the stack - is where you remove data from the stack - set to either end of the linear sequence of data, but only one end

Removing a element from a queue can be called ( This is a multi answer question - check all that are true )

- pop - dequeue - remove

When you try to remove data from a stack and there is nothing there, you are experiencing stack....

- underflow

How can you implement a BST ?

A Binary Search Tree (BST) can be implemented using an array, pointers, or a predefined set class either iteratively or recursively. If implementing a Binary Search Tree with pointers you must have a function that can create nodes and stores data either a string, integer or other. To insert nodes into a Binary Search Tree, you must find a spot for the data in the node because child values less than the parent are sent into the left subtree while child values that are greater are sent to the right of the subtree. To find a spot for the data, you can use recursion to repeat the traversal until you find a spot to place the node.

Define a BST

A Binary Search Tree is a a binary tree with added restrictions, the nodes are sorted in sibling order. BST's are acyclic, a logical hierarchy, and the sort order is left-right sibling sort order, where left child key values must be less than the parent and the right child key value must be greater or equal to the parent. Ways to traverse the BST is either by PreOrder, InOrder, and PostOrder, either recursively or index.

Define a Class. Give its syntax.

A class is a concept, a class can consist of attributes and behaviors. Additional information about a class is that it is a user defined data type that has the ability to create objects that have properties and actions/methods that an object can perform. The syntax for a class is: class nameOfClass { private: public: }:

What are collisions? How can you resolve them?

A collision is something that is caused by when using a hash function. A collision is simply when the hash function produces duplicate indexes (a duplicate key that would locate an array element already in use). To resolve collisions, we can use open addressing, which are methods that look for empty elements in an array. The methods consist of linear probing (move through the array until you find a vacant cell), quadratic probing (moving down the array in increasing increment until you find a vacant cell), and double hashing (having two different hash functions where if the first one results in a collision, the second hash function adds to the first hash function result to produce a whole new key). Lastly, another method to resolve collisions is by rehashing, making a larger array and copying data to it. Basically, you rehash each value in the older array and add each value to a new array and reinsert each entry.

How is a concept like a class?

A concept is like a class because like concepts, one can create concepts from concepts. Classes in object-oriented programming can do the same, classes from classes which is called inheritance. In addition, concepts are formed by many observations, and in a class, it can contain many properties of an object and actions that an object can do. Creating classes and concepts that help an individual overcome the limits of the CROW, which is the number of things that a person can hold in their mind at once.

What is NOT true about recursion?

A function can be written to pass information into it and return an answer. If this function is used in recursion, it would be called THREE-WAY recursion.

List three specific uses of an ADT graph. Explain why for each...

Abstract Data Type Graphs are used everywhere! Three main areas where graphs are used today can be in a social network, using a graph to recommend friends that are friends of your friend. A global position system, using shortest path algorithms to determine the fastest way to get from your starting point to your destination. Lastly, a flight network, the airports can be represented as your nodes while the distance between these airports can be a representation of your edges. The weighted edges allow you to determine the fastest way to get to the destination without taking as many stops.

The UML represents the Stack....

Abstraction

Define the ADT Hash Table. Why use one?

An ADT Hash consists of two main parts, the hash table and the hash function. The hash table is used to store information, while the hash function uses a key to generate the location of the data value in the hash table (a key-value pair). The key being the location of the data, and the value being the data that you want to obtain. ADT Hash is widely used due to quickly access data, or a specific piece of data. The keys should be unique. The key is 'hashed' to an address or index for the values location. An incredibly useful way to obtain specific data.

Define an ADT Graph. What are the common methods for a graph?

An Abstract Data Type Graph is a set of items (vertex) and the connections between them (edges). Connections are acyclic, undirected, and direction. Edges can have values, which are called weights. A completed graph means that each node is connected to all other nodes. Some common methods of a graph can consist of adding a vertex, adding a edge, removing a vertex or edge, giving values to the edge and vertex, a method for the number of edges and vertices in a graph, check if the graph is filled with data or is empty, and three algorithms Dijsktra's shortest path, Depth First Search (DFS), and Breadth First Search (BFS). These algorithms are commonly used in coding interviews are super important to acquiring a job for FAANG companies.

Define the ADT LIST

An abstract data type list is an unsorted linear sequence of data.

'Concepts' and the 'Conceptual Hierarchy' directly correspond to what computer programming concepts...

Class and Inheritance Hierarchy

________________ is the act of looking at many things, selecting out those that have similar (defining characteristics) and creating a word that is used to represent ALL those specific things: past, present and future.

Concept Formation

What is true about this statement: vector <int> myIntVector2 ( 100, 0 );

Creates 100 vector elements Assign 0 to all the vector elements Declare a vector called myIntVector2

The _____________ is the characteristic(s) that explain the most about a thing.

Defining Property

Which is not a method for an ADT queue?

DeleteMiddleValues

A Vectors main feature is it has a....

Dynamic size

A heap is only a binary tree structure and parent child order

False

All heaps must be complete

False

An ADT Set can never be implemented with a BST

False

An ADT Set is the same as an ADT Bag

False

An ADT set can have ordering

False

An isEmpty function is not necessary in a heap

False

Is this a binary heap ? ( 8) / \ (13) (10) / \ \ (1) (6) (14) / \ (4) (7) true = yes false = no

False

It is OK to sort the data in a stack..

False

O(1) is better than O(N!)

False

You can access the data in the middle of a stack

False

You should NEVER question the validity of data. You should ALWAYS make fun of those who do question data.

False

How many cells/elements are in this vector ? vector <int> myIntVector1(4)

Four

The mature adult mind...

Functions on the level of 1st level and higher concepts

What is true about a queue?

It is a list with the added restriction of First in First Out

What are its pros and cons of a BST ?

Pros for a Binary Search Tree is that the Big O for Searching, Insertion, and Deletion of nodes in the BST is O(log(n)). This outperforms sorted arrays, and linked lists. But unfortunately, Binary Search Trees are not as efficient when they are unbalanced. If the Binary Search Tree is not balanced, then the Big O for the methods listed above would be worse. Fortunately you can rebalance a Binary Search Tree which allows it to maintain time efficiency.

Explain the difference between Sort and Search.

Sort or sorting is when you rearrange elements in list/array in a specific order. Search or searching is when one is attempting to find if a specific element in the array exists in a data structure. There are sorting algorithms which are methods to rearrange elements in a given data structure in a specific order, and there are searching algorithms which are methods to find a specified element in a data structure. Rearranging elements, and finding elements.

What are the steps from data to implementation

Steps from data to implementation is to collect your data, validate your data (check if fraud and in range), organize your data, use an algorithm to create a program, and run analysis of the chosen algorithm using Big O Notation.

Which is not an example of a stack

The line at the bus stop

What are the pros and cons of implementing an ADT LIST with pointers?

The pro of implementing an abstract data type list with pointers is that there is an infinite size, unfortunately when using pointers, a con may be that more memory is needed than when using an array.

What are the pros and cons of implementing an ADT LIST with an array?

The pros of implementing an abstract data type list with an array is that the data is accessible with a for loop, unfortunately, a con may be that there is a fixed size when implementing an abstract data type list with an array.

What is the best way to implement an ADT graph

The the main two ways to implement an Abstract Data Type Graphs is by using arrays, pointers, or vectors, unfortunately there is no predefined code for an abstract data type graph. But the two main ways that these fascinating graphs are implemented by either using an adjacency list or a adjacency matrix. After reviewing many videos on both of these implementations, the better way to implement an ADT Graph is by using an adjacency list because it has space complexity of O(n) while a matrix has space complexity of O(n^2). The adjacency list outperforms the adjacency matrix in space complexity and therefore is the clear winner for the better way to implement an ADT graph.

Define the characteristics of an ADT

The two key feature of an ADT is organization and access. Organization is how the element in the data structure are sorted. Access is the coder plans to access the elements in the data structure. In heap element are organized depending whether you are using a max heap or min heap. To access a child element you use the parent index and divided by two.

Define the adjacency matrix for V = ( A, B, C, D) E = ( AB, DB, BC, DC, CC)

This Abstract Data Type Graph has four vertices (A, B, C, and D). A is connected to B, D is connected to B, B is connected to C, D is connected to C, and C loops back to itself.

A balanced BST is a good way to implement a set

True

A heap can either be a min or max heap

True

A key characteristic of an ADT implementation is method to check if a element is a member

True

A stack is a linear data structure that has LIFO data access

True

A tree can have as many nodes as you need, is called an n-ary tree

True

A tree that has only zero up to two(2) nodes per parent is called a Binary tree

True

Adding and removing an element from a stack is called push and pop Correct! True

True

An ADT Bag can have duplicates

True

An ADT LIST is a type of tree where each node has only one child.

True

An ADT Set can have no duplicate elements

True

An ADT does not constrain how you organize the data or how you implement the operations

True

As a programmer you should be aware of all steps for data to implementation

True

Enqueue can also be called push

True

Heaps are NEVER sorted in sibling order

True

Heaps are only sorted in Parent Child order

True

If you implement a heap with an array.. then you should check for stack underflow and overflow

True

In a ADT Queue, the order of the data can not be changed

True

In a complete binary heap you should add the new element to the bottom level and fill from the left to the right

True

Programs = Data + Algorithms

True

Recursion is the repetition of series of steps, and while doing so, breaks a problem down into successive smaller parts until they reach a situation where you can no longer break it into smaller parts... This smallest part is called the base or ending case.

True

The ADT Set should be implemented to have a size method

True

The Big O for the equation: 2n + 1 is O(2)

True

The Vector class is in the Standard Template Library <vector>

True

The addElement method for the implementation of an ADT Set should check first for isElement

True

The essential characteristics of an ADT TREE* is a set of objects with interconnections,* where the interconnections must be acyclic.

True

To implement an ADT stack that has a fixed amount of data you can use an array.

True

To remove/pop an item from a heap, it is taken from the root of the tree

True

Vectors normally allocate some extra storage to accomodate for future possible growth.

True

When a value is inserted in a heap, you may have to shuffle up the value to keep the right sort order

True

When implementing a queue with an array, simply speaking, you could start adding data at element 1 of the array, and add 1 the front index each time you add more data. Be sure to code the array beginning and ending cross over.

True

When implementing a queue with an array, simply speaking, you could start remove data by subtracting 1 from the end index. Be sure to code the array beginning and ending cross over.

True

When you implement a tree, you can use either an array or a pointers

True

Your choice to think or not to think will determine how successful you can identify things in the world and put them together into a crystal clear understanding of the world. When you function on the adult level of thought, then you can be creative and productive, thus enjoying life.

True

What is Tree underflow

Try to delete a node from an empty tree

What is of less concern with data

UML Diagram

What is Big O

Used to describe the performance or complexity of a chosen algorithm. Programmers use Big O Notation to compare which algorithm is best to use for their specific situation. Most importantly, the Big-O informs the programmer about an algorithm's worst case. Worst case is when a lot of data is inputted into the algorithm which informs the programmer on how fast the algorithm can process an immense amount of data.

The focus is

What you choose to hold in your mind

How many cells/elements are in this vector ? vector <int> intVector;

Zero

Which is not an action for a stack

bottom

Sensations are...

many individual stimuli

How can you add assign a value to an existing vector element ? vector <int> myIntVector3 ( 100, 0 );

myIntVector3[0] = 42; myIntVector3.at(21) = 42;

An implemented two-directions Pointer Queue commonly have what in their Nodes..

ptrLeft, Data, ptrRight

How can you clear all element from a vector ?

vectorName.clear();

How can you add a element to the end a vector ? vector <int> vectorName;

vectorName.push_back( value ) ;


Related study sets

欢乐伙伴 5B 第12课(听写)

View Set

International Business Chapters 1-3

View Set

Chapter 4 - Intermediate Accounting Spiceland 9e

View Set

Multiple choice (speech Ballard)

View Set

Chapter 30: Ecology and PopulationsAssignment

View Set

ATI RN MENTAL HEALTH EXAM 2023 WITH NGN

View Set

Chemistry- Polyatomic Ions & Molecular compounds

View Set

Chapter 13: Genuineness of Assent and Undue Influence

View Set

Leading the Public Relations Function Q's

View Set