• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 6 páginas
Examen

Data Structures and Algorithms Python Questions and Answers

Document preview thumbnail
Vista previa 2 fuera de 6 páginas

Data Structures and Algorithms Python Name Every Data Structure (There are 8 Main Ones) - Answer- 1. Array 2. Stack 3. Queue 4. Linked Lists 5. Hash Table 6. BST 7. B-Tree, Red Black Trees 8. Heaps Name Every Python Super Basic Datastructure - Answer- 1. List 2. Tuples 3. Sets 4. Strings 5. Arrays (you must use numpy) Strings - Answer- 1. They are immutable 2. Access characters in strings like you do for arrays/lists 3. empty strings are false, non empty are true. 4. | and & don't work on strings Slicing - Answer- string_name[beginning:end:step] *end is not inclusive *works for strings, lists, and tuples Useful String Methods - Answer- 1. s[3] 2. s + t 3. len(s) 4. s in t 5. () 6. swith(prefix) 7. ith(suffix) 8. (substring, beg, end) - returns the first position where substring is found. 9. (substring, beg,end) - returns the position of the last occurrence of string 10. () - changes case 11. () - changes case 12. ase() - changes to other case Python List - Answer- 1. not always homogenous 2. mutable 3. used to implement stacks and queues Python List Methods - Answer- 1. append(x) 2. extend(x) 3. insert(i, x) 4. min(list) 5. max(list)

Vista previa del contenido

Data Structures and Algorithms Python
Name Every Data Structure (There are 8 Main Ones) - Answer- 1. Array
2. Stack
3. Queue
4. Linked Lists
5. Hash Table
6. BST
7. B-Tree, Red Black Trees
8. Heaps

Name Every Python Super Basic Datastructure - Answer- 1. List
2. Tuples
3. Sets
4. Strings
5. Arrays (you must use numpy)

Strings - Answer- 1. They are immutable
2. Access characters in strings like you do for arrays/lists
3. empty strings are false, non empty are true.
4. | and & don't work on strings

Slicing - Answer- string_name[beginning:end:step]
*end is not inclusive
*works for strings, lists, and tuples

Useful String Methods - Answer- 1. s[3]
2. s + t
3. len(s)
4. s in t
5. s.strip()
6. s.startswith(prefix)
7. s.endswith(suffix)
8. s.find(substring, beg, end) - returns the first position where substring is found.
9. s.rfind(substring, beg,end) - returns the position of the last occurrence of string
10. s.lower() - changes case
11. s.upper() - changes case
12. s.swapcase() - changes to other case

Python List - Answer- 1. not always homogenous
2. mutable
3. used to implement stacks and queues

Python List Methods - Answer- 1. append(x)
2. extend(x)
3. insert(i, x)
4. min(list)
5. max(list)

, 6. del a[i:j]
7. a.reverse()
8. a.sort()
9. B = copy.deepcopy(A)
10. b = copy.copy(A)
11. remove(index)

Tuples - Answer- 1. collection of python objects separated by commas
2. immutable
3. use () to create

Tuples Methods - Answer- 1. len(tuple_name)
2. tuple(list_name)
3. cmp() - returns 0 if matched. 1 when not matched and longer, -1 when not
matched and shorter
4. max() - returns max el
5. min() - returns min el

Python Sets - Answer- 1. unordered collection data type that is iterable, mutable, and
has no duplicate elements
2. based on datastructure known as hash table
3. highly optimized for checking contains
4. to create a set you need to use set(list)
*Only instances of immutable types can be added to python set

Methods - Answer- 1. add(x)
2. union(other)
3. intersect(other)
4. difference(other)
5. clear()
6. set(list) - create a set

Arrays - Answer- 1. There is no built in support.
2. Use numpy arrays
3. To create: np.array([][][]) where each list is its own row

Numpy Array Methods - Answer- ?

Python Dictionaries - Answer- 1. To construct: {key:value,key:value ...}
2. To add key,value pair: dic[new_key] = new_value

Dictionaries Methods - Answer- 1. str(dic) - string of key value pairs
2. items() - returns list of all dictionary keys
3. len() - number of key entries
4. clear()
5. fromkeys(seq, value) - declare new dic form sequence, initialize dic with values

Linked List - Answer- Similar to lists but use it when inserting and deleting a lot.

Linked List Implementation - Answer- class LinkedList():

Información del documento

Subido en
18 de agosto de 2024
Número de páginas
6
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$10.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Freshy
3.6
(11)
Vendido
65
Seguidores
4
Artículos
6964
Última venta
1 día hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes