Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ DSA cheatsheet #232

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CuriousRadhika
Copy link

@CuriousRadhika CuriousRadhika commented Oct 29, 2022

What does this PR do?

Add new CheatSheet

Description

C++ Data Structures and Algorithms Cheat Sheet

Checklist:

Follow-up

  • Check the status of GitHub Actions and resolve any reported warnings!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great having you contribute to this project

Welcome to the community 🤓

Thanks for joining our community - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.

@crescentpartha crescentpartha added hacktoberfest Hacktoberfest Participation hacktoberfest-2022 Hacktoberfest-2022 Participation 📝review-pull-request Reviewing your pull request labels Oct 29, 2022
@CuriousRadhika
Copy link
Author

please merge the pr

Copy link
Owner

@crescentpartha crescentpartha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me good!

Some modifications needed based on requirements:

  1. Rename your file form C++ DSA cheatsheet.md to cpp-dsa-cheatsheet.md or dsa-cheatsheet.md
  2. Remove STL Library from this file and modify cpp-stl-cheatsheet.md by adding time/space complexity, operation-wise complexity, list of operations, use for and not use for in different DSA etc.
  3. Link cpp-stl-cheatsheet.md inside this file.
  4. Maintain the tabular format.

Comment on lines +43 to +49
![Legend](General/Legend.png)

![DataStructures](General/Data%20Structures.png "Data Structures")

![ComplexityChart](General/Complexity%20Chart.png "Complexity Chart")

![DataStructureSelection](General/Data%20Structures%20Selection.png "Data Structures Selection")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those images are not showing.

Comment on lines +11 to +17
- [1.2 Vector `std::vector`](#12-vector-stdvector)
- [1.3 Deque `std::deque`](#13-deque-stddeque)
- [1.4 List `std::list` and `std::forward_list`](#14-list-stdlist-and-stdforward_list)
- [1.5 Map `std::map` and `std::unordered_map`](#15-map-stdmap-and-stdunordered_map)
- [1.6 Set `std::set`](#16-set-stdset)
- [1.7 Stack `std::stack`](#17-stack-stdstack)
- [1.8 Queue `std::queue`](#18-queue-stdqueue)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a cpp-stl-cheatsheet.md sheet. You could check it.

I think it will be better if you add time/space complexity and operation-wise complexity in a tabular format in cpp-stl-cheatsheet.md sheet and just mention that sheet in cpp-dsa-cheatsheet.md.

We could rather use this sheet as a CPP DSA cheatsheet for the most commonly used DSA.

Comment on lines +406 to +424
```c++
std::stack<int> s;

//---------------------------------
// Container-Specific Operations
//---------------------------------

// Push
s.push(20);

// Size
unsigned int size = s.size();

// Pop
s.pop();

// Top
int top = s.top();
```
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```c++
std::stack<int> s;
//---------------------------------
// Container-Specific Operations
//---------------------------------
// Push
s.push(20);
// Size
unsigned int size = s.size();
// Pop
s.pop();
// Top
int top = s.top();
```
Command Description
stack<int> s; Stack Initialization
s.push(20); Push a element on the top
s.pop(); Pop a element from the top
s.top(); Find the top element
s.size(); Find the size of a stack

I think this tabular format is better to understand what type of operations are exists in Stack. After that, you can give an example like these codes.

// Initialization
std::stack<int> s;

// Push
s.push(20);

// Size
unsigned int size = s.size();

// Pop
s.pop();

// Top
int top = s.top();

@crescentpartha crescentpartha added modifications-needed Modify the code waiting-for-changes Waiting for require changes labels Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest Hacktoberfest Participation hacktoberfest-2022 Hacktoberfest-2022 Participation modifications-needed Modify the code 📝review-pull-request Reviewing your pull request waiting-for-changes Waiting for require changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants