{ "@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" } }

Programming Questions Flashcards

(11 cards)

1
Q

What is a set in Python

A

Set is a collection of Unique Elements.
They are mutable = > add or remove elements
IF you add duplicate element it will be ignored

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

Create a set in python

A

set1 = set([1,2,3])

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

What is Time complexity to search for an element in SET in python and Why?

A

O(1) since underlying is hashtable. Python calculates the hashvalue and find the memory address directly.

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

Inorder traversal Use

A

used for binary search trees to get nodes in sorted order.

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

Preorder traversal Use

A

1) useful for creating a copy of the tree.
2) create a copy of the tree.

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

Postorder traversal Use

A

1) used in expression trees to evaluate expressions.
2) used to delete the tree
3) Garbage collections

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

Level order traversal Use

A

1) search or process nodes level-by-level.
2) finding the shortest path between nodes.
3) Tree Serialization and Deserialization

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

Inorder

A

Left -> Root -> Right

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

Preorder

A

Root -> Left -> Right

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

Post Order

A

Left -> Right -> Root

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