Computer Science 101 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the two states in binary due to electricity switches?

A

0 (off) and 1 (on)

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

What numbering system do humans commonly use?

A

Decimal system (0-9)

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

How is a number incremented in the binary system?

A

After a bit reaches 1 in binary, an increment resets it to 0 but also causes an increment of the next bit to the left: 0000, 0001, (rightmost bit starts over, and the next bit is incremented)

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

What is the base of the binary number system?

A

It uses base 2, so counting like 1, 2, 4, 8 …

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

How do you convert a binary number to a decimal number?

A

Add the values of the positions with a 1, from right to left, using powers of 2.

Example:
128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 1 = 179

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

How do you convert a decimal number to a binary number?

A

write out the ^ to the power of numbers, working from the biggest number, subtract the numbers and put a 1 next to them until you’re left with 0

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

What is a logarithmic function?

A

The opposite of an exponential function; it increases quickly at first and then levels out.

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

What is an exponential function?

A

A function that increases rapidly - like timesing itself

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

Why is the growth pattern of n-notation important?

A

It allows comparing the efficiency and scalability of algorithms by understanding how their performance changes with increasing input size.

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

What is the Big O notation used for?

A

To represent the upper bound of the time complexity of an algorithm, indicating the worst-case scenario.

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

What does O(n) signify in Big O notation?

A

Linear time complexity

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

What does O(1) signify in Big O notation?

A

Constant time complexity (the time it takes to complete its task is constant and does not change with the size of the input data)

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

What is a fixed array?

A

An array with a predefined size. (you’re asking the computer to look through its hard drive, find a slot with room for the array - for example 3 pieces of data.)

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

What is a dynamic array?

A

An array that can grow in size as needed.

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

What would the run time be (using big O) to insert randomly into a fixed array?

A

O(n) - inserting randomly requires moving data around in the array, at worst it will need to move every item in the array

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

What is a linked list?

A

A data structure where each element (node) points to the next, and sometimes the previous, element.

17
Q

What is the difference between a singly and doubly linked list?

A

A singly linked list has nodes that point only to the next node, while a doubly linked list has nodes that point to both the next and the previous nodes.

18
Q

What is a stack?

A

A data structure that follows the Last In, First Out (LIFO) principle. (like a stack of trays in a canteen - grab and add from the top)

19
Q

What is a queue?

A

A data structure that follows the First In, First Out (FIFO) principle.

20
Q

What is a binary search tree (BST)?

A

A tree structure where each node has at most two children, and the left child is less than the parent node, while the right child is greater.

21
Q

What is a heap?

A

A tree-based data structure where the parent node is either greater than (max heap) or less than (min heap) its children.

22
Q

What is the purpose of a priority queue?

A

To manage elements based on their priority, where higher priority elements are served before lower priority ones.

23
Q

What is a graph?

A
  • A collection of nodes (vertices) connected by edges.
  • Nodes represent entities such as cities, people, or web pages.
  • Edges represent the relationships or connections between nodes, such as roads between cities, friendships, or hyperlinks.
  • Graphs can be directed (edges have a direction) or undirected (edges have no direction).
  • Common uses include representing networks, social connections, and pathways.
24
Q

What is the difference between directed and undirected graphs?

A

Directed graphs have edges with a direction, while undirected graphs have edges with no specific direction.

25
Q

What is a weighted graph?

A

A graph where edges have weights representing the cost or distance between nodes.

26
Q

What is a depth-first search (DFS) in graph traversal?

A

A graph traversal method that explores as far as possible along each branch before backtracking.

27
Q

What is a breadth-first search (BFS)?

A

A graph traversal method that explores all nodes at the present depth before moving on to nodes at the next depth level.

28
Q

What is recursion, and how is it used in sorting algorithms?

A
  • Recursion is a function calling itself, similar to a nested loop.
  • It ensures the function doesn’t run indefinitely, as each call is pending a return statement.
  • Commonly used in divide-and-conquer sorting algorithms like Quick Sort and Merge Sort.