Python Built-In Data Structures Flashcards

1
Q

Python has 4 types of built-in data structures, they are?

A

lists,

tuples,

dictionaries,

sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which two types of python data structures are mutatable?

A

lists and dictionaries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What python data types are not mutable?

A

tuples and sets.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Python lists are created by?

A

[]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Python sets are created by?

A

{ }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Python dictionary are created by?

A

{ }

dict( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Python tuples are created by?

A

( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Cite the data structure?

a = [“apple”, “banana”, “cherry”]
print(a)

A

list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Cite the data structure?

a = (“apple”, “banana”, “cherry”)

A

tuple

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Cite the data structure?

a = {“apple”, “banana”, “cherry”}

A

set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Cite the data structure?

a = {
“brand”: “Ford”,
“model”: “Mustang”,
“year”: 1964
}

A

dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

______ items are ordered, changeable, and allow duplicate values.

______ items are indexed, the first item has index [0], the second item has index [1] etc.

A

List

List

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

____ items are ordered, unchangeable, and allow duplicate values.

____ items are indexed, the first item has index [0], the second item has index [1] etc.

A

tuple

tuple

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

____ items are unordered, unchangeable, and do not allow duplicate values.

A

set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

_____ items are unordered, changeable, and does not allow duplicates.

_____ items are presented in key:value pairs, and can be referred to by using the key name.

A

dictionary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Cite 6 user type data structures in python3

A

stacks,

queues,

trees,

linked lists,

graphs,

hashmaps.

17
Q

Last in first out (LIFO) describe what user type data structure?

A

stacks

linear data-structure, reversing words, recursion programming, word editors,

18
Q

First in first out (FIFO) describe what user type data structure?

A

queues

about: linear data structure, array structured, heads & tails, traffic congestion management, dequeue, enque to remove elements, job scheduling (ie print que)

19
Q

A non linear data structure ecompassing a root and nodes is what type of user defined data structure?

A

trees

about: parent child relationships, last node are described as leaves, hierarchy structured (ie web pages), efficient at searching

20
Q

A linear data structure that isn’t sorted and utilizes pointers describes what user defined data structure?

A

linked list

about: image viewing, pointers -> next, used in music player applications,

21
Q

What user defined data structure encompasses pointers, vertices and edges

A

graphs

about: real world example of a map, used by Google map, used to determine quickest most efficient routes between nodes or points, used by Uber.

22
Q

What user defined data structure can define a dictionary like structure much like a phone book?

A

hashmaps

about: identical as a dict object in python, used in applications like phone books,

populate data from a list,

23
Q

_________ are rules or instructions that are formulated in a finite, sequential order to colve problems. They provide the ________ for problems.

A

algorithms

pseudocode

24
Q

What are the 5 steps involved in writing algorithms?

A
  1. determine the exact problem
  2. define start
  3. define stop
  4. formulate intermediate steps
  5. review
25
Q

Elements of a good algorithm are:

A
  • finite, clear, and understandable.
  • clear and precise description of input and outputs.
  • each step must have a defines output that depends only on inouts in that step of the preceding steps.
  • should be flexible.
  • every step should make use of general programming fundamentals and be language agnostic.
26
Q

Cite three algorithms classes?

A

divide & conquer

dynamic programming

greedy algorithms

27
Q

“Divides the problem into sub parts and solves each on separately” describes which algorithm class?

A

divide & conquer

28
Q

“Divides the problem into sub-parts, remembers the results and applies it to simliar ones” describes which algorithm class?

A

dynamic programming

29
Q

“Involves taking the easiest step while solving a problem without worrying about the complexity of the future steps” describes which algorithm class?

A

greedy algorithm

30
Q

Cite the 3 types of tree traversals?

A

In-order

pre-order

post-order

31
Q

______ traversal refers to visiting the left nodes followed by the root and then right nodes.

A

in-order

32
Q

______ traversal refers to visiting the root nodes followed by the left nodes and then right nodes.

A

pre-order

33
Q

_______ traversal refers to visiting the left nodes followed by the right nodes and then root node.

A

post-order

34
Q

Cite the five(5) sorting algorithms types?

A
  1. merge
  2. bubble
  3. insertion
  4. selection
  5. shell
35
Q

What type of algorith​m follows the divide & conquer rule and the given list is divided into smaller lists and compared to adjacent lists and then reorders in the desired sequence all using recursion?

A

merge sort