045-Python知识点(6-9)

045-Python知识点(6-9)

第9周

第01题。

What is algorithm
An algorithm is a finite set of instructions which accomplish a particular task.
An algorithm is a finite set of instructions which accomplish a particular task.

第02题。

What is data structure?
A data structure is an organization of information, usually in memory, for better algorithm efficiency.
A data structure is an organization of information, usually in memory, for better algorithm efficiency.

第03题。

What is the relationship between data structure and algorithm
Most data structures have associated algorithms to perform operations, such as search, insert and delete, that maintain the properties of the data structure.

第04题。

What are common data structure types?
1.Array and Sorted Array
2.Queue
3.Stack
4.Linked List
5.Heap
6.Tree
7.Graph

8.Hash

-

1.Heap
2.Stack
3.Array and Sorted Array
4.Linked List
5.Hash
6.Graph
7.Queue
8.Tree

第05题。

What is abstract data type? (ADT)
Abstract data types are defined independent from implementation.
Abstract data types are defined independent from implementation.

第06题。

What is a stack?
A stack is a container of objects that are inserted and removed according to the last-in-first-out principle.
A stack is a container of objects that are inserted and removed according to the last-in-first-out principle.

第07题。

What is queue?
Queue is a container of objects that are inserted and removed according to the first-in-first-out(FIFO) principle.
Queue is a container of objects that are inserted and removed according to the first-in-first-out(FIFO) principle.

第08题。

Try to define class Stack
class Stack(Container):
    def push(self, element):
        self.elements.append(element)
    def pop(self):
        return self.elements.pop()
    def top(self):
        return self.elements[self.size-1]

第09题。

Try to define class Queue
class Queue(Container):
    def enqueue(self, element):
        self.elements.insert(0,element)
    def dequeue(self):
        return self.elements.pop()
    def front(self):
        return self.elements[self.size-1]

第10题。

What is analysis of algorithm
Analysis is the process of deriving estimates for the time and space needed to execute the algorithm.
Analysis is the process of deriving estimates for the time and space needed to execute the algorithm.

第11题。

What is the running time of append() and insert()
1.append() taks a constant number of step, so we say the running time of append() is O(1)
2.insert() takes a maximum of n step, so we say the running time of insert() is O(n)

第12题。

The worst-case time of if-else.
if condition:
    sequence 1
elif:
    sequence 2
else:
    sequence 3
The worst-case time is
    Max(time(sequence 1), time(sequence 2), time(sequence 3))

第13题。

The total time for the loop.
for i in range(N):
    sequence of statements
Assume the statements are O(1), the total time for the for loop is O(N).
If N is 100, the total time is O(100).

第14题。

Nested loops
for i in range(N):
    for j in range(M):
        sequence of statements
the complexity is O(N*M)

第15题。

Statements with method calls
for i in range(N):
    method(N)

The complexity is O(N^2)

第16题。

Efficiency of Stack and Queue
Stack
    push()    O(1)
    pop()    O(1)
Queue
    enqueue()    O(n)
    dequeue()    O(1)

第7周

第01题。

What is regular expression?
A regular expression is a special sequence of characters that are used to find or match a set of strings.
A regular expression is a special sequence of characters that are used to find or match a set of strings.

第02题。

Common re syntax
.    any character
[abc]    a or b or c
[^ab]      any but a or b
\d    digits [0-9]
\D     no digits [^0-9]
-w    any alpha [a-zA-Z0-9_]
-W     any but [^a-zA-Z0-9_]
x?    x zero or one time
x*     x zero or more times
x+    x one or more times

第6周

第01题。

What is database?
A database is an application that stores a collection of data.
A database is an application that stores a collection of data.

What is Database APIs?
Database APIs are for accessing, creating, managing, searching and replicating data held in a database.

What is relational database?
A Relational Database holds all the data in different tables and relations are established using primary keys and foreign keys.

第02题。

What is primary key?
A primary key is a field in a table whose value is used to uniquely identify a record in the table.
 
What is foreign key?
Foreign key is a column of a table that reference a primary key in another table.

第03题。

What is SQL?
Structured Query Language is a standard language for accessing databases.

第04题。

1.create databases and tables
2.retrieve/insert/update/delete records from a database
3.execute queries against a database
4.set permissions
5.create views

第05题。

What is DML DDL?
Data manipulation language:
select, update, delete, insert into
Data Definition language
create database, alter database, create table, alter table

第06题。

What is SQLite
SQLite is an embedded relational database engine and implements most of the SQL-92 standards.

第07题。

Common sql
CREATE TABLE authors(id INTEGER PRIMARY KEY, title TEXT NOT NULL);
INSERT INTO authors values(1,"Bob");
SELECT * FROM authors;
SELECT * FROM authors WHERE id=1;

第08题。

发布了1081 篇原创文章 · 获赞 42 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/qq_33781658/article/details/103900915