WILL PASS :)

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Returns the number of items in the list

GetLength(list)

Returns the number of items in the queue

GetLength(queue)

Executing the statements: address = '900 University Ave' address[0] = '6' address[1] = '2' is a valid way to change address to '620 University Ave'.

In-place modification of string variables is not allowed.

Inserts x after w

InsertAfter(list, w, x)

Returns true if list has no items

IsEmpty(list)

Returns true if queue has no items

IsEmpty(queue)

is a data structure that stores an ordered list of items in nodes, where each node stores data and has a pointer to the next node.

a linked list

is a tree that maintains the simple property that a node's key is greater than or equal to the node's childrens' keys.

a max heap

is a tree that maintains the simple property that a node's key is less than or equal to the node's childrens' keys.

a min heap

an underscore

is considered to be a letter.

A variable

is used to remember a value for later use

Reserved words are also known as

keywords

Find the length of the list.

len(list)

Sequence type: A mutable container with ordered elements.

list

Common supported ADTs Python

list, set, dict, deque

The first array element is accessed using array[0], but the first linked list item is accessed using

list->head. So, different algorithms are needed for an array and linked list.

Count the number of occurrences of the value val in list.

list.count(val)

Find the index of the first element in list whose value matches val.

list.index(val)

Produce a new list by concatenating list2 to the end of list1.

list1 + list2

Find the element in list with the largest value.

max(list)

Find the element in list with the smallest value.

min(list)

Write an expression that accesses the first character of the string my_country.

my_country[0]

* and / have precedence over + so will be evaluated first. * and / have equal precedence

so are evaluated left-to-right, despite what the original spacing implied.

The two operators have equal precedence,

so the interpreter evaluates left-to-right.

Find the sum of all elements of a list (numbers only).

sum(list)

a built-in function id()

that gives the value of an object's identity.

Knowledge of an ADT's underlying implementation is needed to analyze the runtime efficiency.

true

Python, C++, and Java all provide built-in support for a deque ADT. True False

true

Common supported ADTs C++

vector, list, deque, queue, stack, set, map

x is a key in the dict my_dict

x in my_dict

x is less than y but greater than z

z < x < y

A literal

is a specific value in code like 2 or "abc".

Returns but does not remove item at the front of the queue

Peek(queue)

Returns and removes item at front of queue

Pop(queue)

Sorts the lists items in ascending order list becomes: 77, 99

Sort(list)

KeyError occurs

if a requested key does not exist in the dictionary.

An operator

is a symbol for a built-in language calculation like + for addition.

num_dogs is either less-than or greater-than num_cats

!=

python is case sensitive, so

"cat" and "Cat" are different.

2 times x is less than 100

(2*x) < 100

x is an even integer

(x % 2) == 0

Arithmetic operators look like

+ * // /

% has precedence over

+ so is evaluated first.

Inserting an item at the beginning of a 999-item linked list requires how many items to be shifted?

0

Inserting an item at the end of a 999-item array requires how many items to be shifted?

0

Inserting an item at the end of a 999-item linked list requires how many items to be shifted?

0

x is a non-negative number less than 100.

0 <= x < 100

Inserting an item at the beginning of a 999-item array requires how many items to be shifted?

999

x is not more than y (using just relational operators)

<=

is an ADT for storing items in which the order does not matter and duplicate items are allowed.

A bag

is an ADT in which items can be inserted and removed at both the front and back.

A deque

s an ADT that associates (or maps) keys with values.

A dictionary

is a data structure that stores unordered items by mapping (or hashing) each item to a location in an array.

A hash table

is an ADT for holding ordered data.

A list

is a queue where each item has a priority, and items with higher priority are closer to the front of the queue than items with lower priority.

A priority queue

is an ADT in which items are inserted at the end of the queue and removed from the front

A queue

is an ADT for a collection of distinct items.

A set

is an ADT in which items are only inserted on or removed from the top

A stack

Executing the statements: address = '900 University Ave' address = '620 University Ave' is a valid way to change address to '620 University Ave'.

A string variable can be reassigned to a new string.

Identity

A unique identifier that describes the object.

represents an item in a graph.

A vertex

Inserts x at end of list

Append(list, x)

Items are not ordered. Duplicate items are allowed.

Bag

Reserved words

Certain words, like "and" or "True" can not be used as names. and thus cannot be used as a programmer-defined name

Common supported ADTs Java

Collection, Set, List, Map, Queue, Deque

Items are ordered based on how items are added. Duplicate items are allowed.

List

The list ['a', 'b', 3] is invalid because the list contains a mix of strings and integers.

Lists can contain mixes of types.

Inserts x at start of list

Prepend(list, x)

Prints list's items in order

Print(list)

Prints list's items in reverse order

PrintReverse(list)

Items are ordered based on items' priority. Duplicate items are allowed.

Priority Queue

Inserts x at end of the queue

Push(queue, x)

Remove(list, x)

Removes x

Returns item if found, else returns null

Search(list, x)

Items are not ordered. Duplicate items are not allowed.

Set

Both the array and linked list have a length subitem.

The algorithm to return the size just return that length subitem.

Type:

The type of the object, such as integer or string.

is a data structure in which each node stores data and has up to two children, known as a left child and a right child.

a binary tree

Division always returns a

a float type

is a data structure for representing connections among items, and consists of vertices connected by edges.

a graph

is the data structure that stores subitems, often called fields, with a name associated with each subitem.

a record

is a data structure that stores an ordered list of items, where each item is directly accessible by a positional index.

an array

A floating-point literal using scientific notation is written using

an e preceding the power-of-10 exponent, as in 6.02e23 to represent 6.02x1023. The e stands for exponent. Likewise, 0.001 is 1x10-3 so can be written as 1.0e-3.

represents a connection between two vertices in a graph.

an edge

Strings are immutable. Once created, they can not be changed. To update a string variable,

an entire new string must be assigned to the variable.

New elements are added to a list using the list method

append()

An assignment statement like num_apples = 8

assigns the name on the left side to reference the value on the right side.

Mutability

indicates whether the object's value is allowed to change, and is explored in another section.

An expression

is a combination of items such as variables, literals, and operators that evaluates to a value. An example is: 2 * (num + 1). If num is 4, then the expression evaluates to 2 * (4 + 1), or 10.

A name, also called an identifier

is a sequence of letters (a-z, A-Z, _) and digits (0-9), and must start with a letter.

Mapping type: A container with key-values associated elements.

dict

What character is in index 2 of the string "America"?

e

The underlying data structure for a list data structure is the same for all programming languages.

false

ADTs are only supported in standard libraries. True False

false third-party libraries, which are not built in to the programming language standard, implement

Add a price to the end of the list with a value of '$1,000,000'.

house_prices.append('$1,000,000')

Assign my_var with the last character in my_str. Use a negative index.

my_var = my_str[-1]

A tuple behaves similar to a list but is immutable

once created the tuple's elements can not be changed.

Elements can be removed using the

pop() or remove() methods.

Print the length of the string first_name.

print(len(first_name))

built-in function type()

prints the type of an object.


Set pelajaran terkait

Ch 8: Sources of Capital for Entrepreneurs

View Set

The First Trimester: Review Questions

View Set

Chapter 13: Reformations and Religious Wars Book Vocab

View Set