{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

Fundamentals of Algorithms (C3) Flashcards

(8 cards)

1
Q

Describe Depth-first searches

A
  • They use a stack, and are used for navigating mazes.
  • Start on a node, go the next adjacent node based on alphabetic order.
  • Add each node you visit to a stack.
  • Once there are no adjacent nodes, pop the top value from the stack, and visit the new top value.
  • Repeat until you reach the end.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe Breadth-first searches

A
  • These use queues, where each node is visited and added to the queue.
  • The next node is taken from the end (so the first one in), as opposed from the top like a stack.
  • So essentially same as depth first, but you look at the BOTTOM of the stack (a queue).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Compare depth first and breadth first searches

A
  • Breadth first uses queues, depth first uses queues.
  • Breadth first better nodes are closer to starting node, depth first better when solutions further away from source.
  • Breadth first worse for decision-making trees.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe pre, in, and post order traversal of a tree.

A
  • Pre (node-left-right): Visit root, left subtree, then right subtree.
  • In (left-node-right): Traverse left subtree, visit root, traverse right subtree. (add from bottom up)
  • In (left-right-node): Traverse left subtree, traverse right subtree, visit node. (add from bottom up)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Uses of RPN

A
  • Expressions are simpler for computers to evaluate using a stack.
  • Eliminates the need for brackets in sub-expressions.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to make bubble sort more efficient?

A
  • Add variable set to true if a swap is made each pass, and change the outer loop so it only runs if the flag variable is set to true.
  • After the inner loop, subtract 1 from N
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does * mean in regex?

A

Zero or more

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

What does ? mean in regex?

A

Zero or one

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