dsa-training's People
dsa-training's Issues
Điều kiện thừa
https://github.com/minhduc9699/DSA-Training/blob/master/stack.py#L9
https://github.com/minhduc9699/DSA-Training/blob/master/queue.py#L9
if len(self.items) == 1 or i == len(self.items) - 1:
Chỉ cần chuyển thành:
if i == len(self.items) - 1:
Vì nếu len(self.items) == 1
mà đúng thì khi i = 0
đương nhiên if sẽ được thoả mãn và white_space
sẽ bằng " "
Thừa biến
Ở trong bài BTree, hàm find()
https://github.com/minhduc9699/DSA-Training/blob/master/btree.py#L49
Biến found sinh ra là không cần vì em không dùng nó vào việc gì cả.
Nếu nói là dùng vào việc kết thúc vòng lặp cũng không đúng vì ngay sau khi để found = True với ý đồ thoát vòng lặp, khi biến này chưa kịp phát huy tác dụng ở vòng lặp tiếp theo, thì đã có return. Khi chương trình gặp return, thì có nghĩa là cả hàm được thoát ra, bao gồm vòng lặp rồi
Suy nghĩ về chuyện chia thành 2 hàm
https://github.com/minhduc9699/DSA-Training/blob/master/btree.py#L36
Ở đoạn này anh hiểu là em định xử lý 2 trường hợp khác nhau, chia thành 1 cái cho trường hợp không có root, và 1 cái thì có root. tuy nhiên khi bóc thành 2 hàm, lại cùng tên, thường chỉ có 2 trường hợp .�Một là hàm con (i.e. _add
) là hàm đệ quy, có tham số đầu vào rất khác với hàm gốc (i.e. `add). Hai là hàm gốc dài và bao gồm các bước cụ thể, bước 1 làm gì, bước 2 làm gì, thì nên tách ra thành các hàm con với tên các hàm là tên các bước tương ứng
Rẽ nhánh lồng nhau không cần thiết
https://github.com/minhduc9699/DSA-Training/blob/master/btree.py#L51
if node.content == val:
...
else:
if val < node.content:
...
else:
...
Có thể chuyển thành:
if node.content == val:
...
elif val < node.content:
...
else:
...
Nhớ để 2 vế giống nhau
nếu đã node.content == val
rồi thì bên dưới nên là node.content > val
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.