9 |
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to the community leaders responsible for enforcement at
63 | kodeflap@gmail.com.
64 | All complaints will be reviewed and investigated promptly and fairly.
65 |
66 | All community leaders are obligated to respect the privacy and security of the
67 | reporter of any incident.
68 |
69 | ## Enforcement Guidelines
70 |
71 | Community leaders will follow these Community Impact Guidelines in determining
72 | the consequences for any action they deem in violation of this Code of Conduct:
73 |
74 | ### 1. Correction
75 |
76 | **Community Impact**: Use of inappropriate language or other behavior deemed
77 | unprofessional or unwelcome in the community.
78 |
79 | **Consequence**: A private, written warning from community leaders, providing
80 | clarity around the nature of the violation and an explanation of why the
81 | behavior was inappropriate. A public apology may be requested.
82 |
83 | ### 2. Warning
84 |
85 | **Community Impact**: A violation through a single incident or series
86 | of actions.
87 |
88 | **Consequence**: A warning with consequences for continued behavior. No
89 | interaction with the people involved, including unsolicited interaction with
90 | those enforcing the Code of Conduct, for a specified period of time. This
91 | includes avoiding interactions in community spaces as well as external channels
92 | like social media. Violating these terms may lead to a temporary or
93 | permanent ban.
94 |
95 | ### 3. Temporary Ban
96 |
97 | **Community Impact**: A serious violation of community standards, including
98 | sustained inappropriate behavior.
99 |
100 | **Consequence**: A temporary ban from any sort of interaction or public
101 | communication with the community for a specified period of time. No public or
102 | private interaction with the people involved, including unsolicited interaction
103 | with those enforcing the Code of Conduct, is allowed during this period.
104 | Violating these terms may lead to a permanent ban.
105 |
106 | ### 4. Permanent Ban
107 |
108 | **Community Impact**: Demonstrating a pattern of violation of community
109 | standards, including sustained inappropriate behavior, harassment of an
110 | individual, or aggression toward or disparagement of classes of individuals.
111 |
112 | **Consequence**: A permanent ban from any sort of public interaction within
113 | the community.
114 |
115 | ## Attribution
116 |
117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118 | version 2.0, available at
119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120 |
121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
122 | enforcement ladder](https://github.com/mozilla/diversity).
123 |
124 | [homepage]: https://www.contributor-covenant.org
125 |
126 | For answers to common questions about this code of conduct, see the FAQ at
127 | https://www.contributor-covenant.org/faq. Translations are available at
128 | https://www.contributor-covenant.org/translations.
129 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check [existing open](https://github.com/kodeflap/Algo_Guide/issues), or [recently closed](https://github.com/kodeflap/Algo_Guide/issues?q=is%3Aissue+is%3Aclosed), issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *master* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request
37 |
38 | ### How to add new features
39 |
40 | 1. Add package name for the feature
41 | 2. If sub features are there create seperate package for it
42 | 3. Add class to it
43 |
44 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
45 | [creating a pull request](https://github.blog/2015-01-21-how-to-write-the-perfect-pull-request/).
46 |
47 | ## Finding contributions to work on
48 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix) and also some additional labels((designing,todo,hacktoberfest,fix,documentation)
49 |
50 | ## Code of Conduct
51 | For more information see the [Code of Conduct FAQ](https://github.com/kodeflap/Algo_Guide/blob/master/CODE_OF_CONDUCT.md)
52 |
53 | ## Licensing
54 |
55 | See the [LICENSE](https://github.com/kodeflap/Algo_Guide/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
56 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [2023] [kodeflap]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
14 |
15 | # About
16 |
17 | The Algo Guide is an educative android app for studying data structures and algorithms. The app includes algorithm concepts and uses simple visual elements like charts, and other visual elements to simplify the understanding of the working of each algorithm like searching, sorting, etc. The app will also be included with code simultaneously to understand the concepts.
18 |
19 | # General Info
20 |
21 | - Different algorithm concepts
22 | - Visualise the best way to make it understandable
23 | - Embedded code to each algorithm concepts
24 | - Making user interface using Jetpack Compose
25 | - Implementing ViewModel concepts
26 |
27 |
28 | # Project Status
29 |
30 | 🚧🚧 Project is: In progress. check out the progress
31 |
32 |
33 | ## Tech stack
34 |
35 |
36 |
37 |
Mobile OS
38 |
Android
39 |
40 |
41 |
Architecture
42 |
Clean Architecture
43 |
44 |
45 |
Programming Language
46 |
Kotlin
47 |
48 |
49 |
Database
50 |
Room
51 |
52 |
53 |
API
54 |
DSA API
55 |
56 |
57 |
UI Framework
58 |
Jetpack compose
59 |
60 |
61 |
Push Notification
62 |
Firebase
63 |
64 |
65 |
66 | ## Feature List
67 |
68 | - Offline access to lesson
69 | - Track lessen progress
70 | - Daily Goal setting and updating
71 | - Daily remainder setting and updating
72 | - Streak Count
73 | - Showing topic covered count
74 | - Showing lessen covered count
75 | - Showing new notification
76 | - Daily goal reached or not progress
77 |
78 | ## Wireframe
79 |
80 | The wireframes are designed using figma. You can view the wireframe by clicking [here](https://www.figma.com/file/hMSxpTN6UzOrkMeWLa5ofY/Algo-Guide-(Copy)?node-id=0%3A1)
81 |
82 | ## Colors
83 |
84 |
85 |
86 |
#17A1FA
87 |
#02F054
88 |
#C7D909
89 |
#F09A02
90 |
#E61902
91 |
92 |
93 |
94 | ## Typography
95 |
96 | - Poppins
97 | - Roboto
98 |
99 | ## Prototype
100 |
101 | For getting details about prototype check out [here](https://www.figma.com/file/hMSxpTN6UzOrkMeWLa5ofY/Algo-Guide-(Copy)?node-id=128%3A98)
102 |
103 | ## Structure the app course
104 |
105 |
106 | ## To Do
107 |
108 | - [ ] API Development
109 | - [ ] Designing using jetpack compose
110 | - [ ] Ds And Algorithm codes - Check out the [ToDo.md](https://github.com/kodeflap/Algo_Guide/blob/master/ToDo.md)
111 | - [ ] Development
112 | - [ ] Unit Testing
113 |
114 | # Getting Started
115 |
116 | ## Prerequisites
117 |
118 | You need to know a basic understanding of
119 |
120 | - Android Fundamentals.
121 | - Kotlin language.
122 | - Clean architecture
123 | - Coroutines
124 |
125 | So let's get started.
126 |
127 | 1. Install Android studio
128 | 2. Install Android SDK(28)
129 |
130 | ### Installation
131 |
132 | 1. Fork the repo
133 | 2. Clone the repo
134 | 3. Start a new project as import from Version Control in android studio and paste the clone URL and finish.
135 | 4. Run your application.
136 |
137 | ## Contributing
138 |
139 | Contributions are always welcome!
140 | Contributions are what make the open-source project amazing. Which helps to learn, inspire, and found new modes in the development phase of a coder. Any contribution to this project is greatly appreciated.
141 | If you have any suggestion or found any issues please free to put your suggestion.
142 |
143 |
144 | If you like to contribute to the project you can check the [CONTRIBUTING.md](https://github.com/kodeflap/Algo_Guide/blob/master/CONTRIBUTING.md) to know how to contribute to the projet.
145 |
146 | That's all
147 |
148 | ## 💭 Needed any help and how to contact
149 |
150 | The project has also discussion section you can discuss an issue or can share your ideas. Let's make it as great
151 |
152 | Also check out the [discord](https://discord.gg/8zdFPzQh) to disucuss
153 |
154 | # Contributors
155 |
156 |
157 |
158 |
159 |
160 | Made with [contrib.rocks](https://contrib.rocks).
161 |
162 | # License
163 |
164 | [Apache license](LICENSE)
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/Resources.md:
--------------------------------------------------------------------------------
1 | # Awesome DS and Algorithm Resources
2 | ![Awesome][awesome-badge]
3 |
4 | Useful resources for developers to refer too! ⚡
5 |
6 | Resources are added frequently! ⚡
7 |
8 | Enjoy!
9 |
10 | If you like this repo, be sure to ⭐ it.
11 |
12 | Please read [`contributing guidelines`](./CONTRIBUTING.md) before submitting new resources.
13 |
14 | ---
15 |
16 | Initially created by [Montek](https://github.com/Montekkundan)
17 |
18 | ## Table of Contents
19 |
20 | - [YouTube links](#youtube-links)
21 | - [Tutorial links](#tutorial-links)
22 | - [Time and Space Complexity](#time-and-space-complexity)
23 | - [Websites](#websites)
24 | - [Others](#others)
25 |
26 | ## YouTube links:
27 |
28 | | Course name | language |
29 | |----------------------------------------------------------------------------------------------------------------------------------------------------|:---------|
30 | | [C++ Full Course C++ Tutorial Data Structures & Algorithms](https://www.youtube.com/watch?v=z9bZufPHFLU&list=PLfqMhTWNBTe0b2nM6JHVCnAkhQRGiZMSJ) | Hindi |
31 | | [Data Structures Easy to Advanced Course - Full Tutorial from a Google Engineer](https://www.youtube.com/watch?v=RBSGKlAvoiM) | English |
32 | | [Java + DSA + Interview Preparation Course](https://www.youtube.com/watch?v=rZ41y93P2Qo&list=PL9gnSGHSqcnr_DxHsP7AW9ftq0AtAyYqJ) | English |
33 | | [Data Structures and Algorithms Course in Hindi](https://www.youtube.com/watch?v=5_5oE5lgrhw&list=PLu0W_9lII9ahIappRPN0MCAgtOu3lQjQi) | Hindi |
34 |
35 |
36 | [⬆ back to top](#table-of-contents)
37 |
38 | ## Tutorial links:
39 |
40 | | Course name | Description |
41 | |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
42 | | [Algorithms Part 1 — Coursera](https://coursera.pxf.io/c/3294490/1164545/14726?u=https%3A%2F%2Fwww.coursera.org%2Flearn%2Falgorithms-part1) | It’s a two-part course, in which the first part covers basic data structures, sorting, and searching algorithms, and the second part focuses on the graph and string-processing algorithms. |
43 | | [Data Structure Free Udemy Course](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fdata-structures-part-1-lognacademy%2F) | The course covers well-known data structures such as dynamic arrays, linked lists, stacks, queues, and binary trees. |
44 | | [Easy to Advanced Data Structures](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fintroduction-to-data-structures%2F) | You will learn about the array, linked list, dynamic array, stack, queue, doubly linked list, priority queues, hash tables, binary search trees, Fenwick tree/binary indexed tree, AVL tree, and Indexed priority queue. |
45 | | [Graph Theory Algorithms](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fgraph-theory-algorithms%2F) | This provides a complete overview of graph theory algorithms in computer science and mathematics. |
46 | | [Dynamic Programming — I](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fdynamic-programming-i%2F) | If you are preparing for job interviews then apart from knowing data structures and algorithms, you should also learn about programming techniques like recursion, iteration, and dynamic programming. |
47 | | [Data Structures Concepts & Singly Linked List Implementation]() | You will learn to implement various linked list operations using the C programming language like finding a node, appending a node, deleting a node, adding a node to a position, traversing a linked list, and preparing a node. |
48 | | [ Introduction to Algorithms and Data structures in C++](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fintroduction-to-algorithms-and-data-structures-in-c%2F) | In this course, you will not only learn about fundamental data structures like an array and linked list, stack, and queue but you will also learn about practical techniques to solve algorithmic problems. |
49 | | [Data Structures in Java for Noobs (Lite Edition)](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fdata-structures-in-java-for-noobs-lite-edition-algorithms-beginners%2F) | You will learn about all the linked list operations and how to implement it using Java Programming language like adding a node, deleting a node from both beginning and end. Overall, a short course to focus on a linked list data structure. |
50 | | [ Getting Interview Ready — Data Structures](https://click.linksynergy.com/deeplink?id=JVFxdTr9V80&mid=39197&murl=https%3A%2F%2Fwww.udemy.com%2Fgetting-interview-ready-data-structures%2F) | This is a great course to learn data structure and algorithms if you are preparing for an interview and don’t have much time. The course is neither very long nor very short and just contains 3 hours’ worth of content. |
51 | | [Algorithms and Data Structures — Part 1](https://pluralsight.pxf.io/c/1193463/424552/7490?u=https%3A%2F%2Fwww.pluralsight.com%2Fcourses%2Fads-part1) | You will learn the trade-offs involved with choosing each data structure, along with traversal, retrieval, and update algorithms. |
52 |
53 |
54 | [⬆ back to top](#table-of-contents)
55 |
56 | ## Time and Space Complexity:
57 |
58 | | Course name | Language |
59 | |---------------------------------------------------------------------------------------------------|:---------|
60 | | [Introduction to Big O Notation and Time Complexity](https://www.youtube.com/watch?v=D6xkbGLQesk) | English |
61 | | [Time Complexity and Big O Notation (with notes)](https://www.youtube.com/watch?v=vgSKOMsjLbc) | Hindi |
62 |
63 |
64 | [⬆ back to top](#table-of-contents)
65 |
66 | ## Websites:
67 |
68 | 🚧 Work in progress....
69 |
70 | ## Others:
71 |
72 | 🚧 Work in progress...
73 |
74 | [awesome-badge]: https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.application'
3 | id 'org.jetbrains.kotlin.android'
4 | id 'org.jetbrains.dokka'
5 | }
6 |
7 | android {
8 | compileSdk 32
9 |
10 | defaultConfig {
11 | applicationId "com.dlight.algoguide"
12 | minSdk 21
13 | targetSdk 32
14 | versionCode 1
15 | versionName "1.0"
16 |
17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18 | vectorDrawables {
19 | useSupportLibrary true
20 | }
21 | }
22 |
23 | buildTypes {
24 | release {
25 | minifyEnabled false
26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
27 | }
28 | }
29 | compileOptions {
30 | sourceCompatibility JavaVersion.VERSION_1_8
31 | targetCompatibility JavaVersion.VERSION_1_8
32 | }
33 | kotlinOptions {
34 | jvmTarget = '1.8'
35 | }
36 | buildFeatures {
37 | compose true
38 | }
39 | composeOptions {
40 | kotlinCompilerExtensionVersion compose_version
41 | }
42 | packagingOptions {
43 | resources {
44 | excludes += '/META-INF/{AL2.0,LGPL2.1}'
45 | }
46 | }
47 | namespace 'com.dlight.algoguide'
48 | }
49 |
50 | dependencies {
51 |
52 | implementation 'androidx.core:core-ktx:1.7.0'
53 | implementation "androidx.compose.ui:ui:$compose_version"
54 | implementation "androidx.compose.material:material:$compose_version"
55 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
56 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
57 | implementation 'androidx.activity:activity-compose:1.3.1'
58 | testImplementation 'junit:junit:4.13.2'
59 | androidTestImplementation 'androidx.test.ext:junit:1.1.3'
60 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
61 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
62 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
63 | debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
64 |
65 | //accompanist
66 | implementation "com.google.accompanist:accompanist-pager:0.12.0"
67 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/dlight/algoguide/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.dlight.algoguide", appContext.packageName)
23 | }
24 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/composables/chapter_screen/ChapterScreen.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.composables.chapter_screen
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.*
6 | import androidx.compose.material.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.graphics.Color
11 | import androidx.compose.ui.res.painterResource
12 | import androidx.compose.ui.text.TextStyle
13 | import androidx.compose.ui.text.font.FontWeight
14 | import androidx.compose.ui.unit.dp
15 | import androidx.compose.ui.unit.sp
16 | import com.dlight.algoguide.R
17 |
18 | @Composable
19 | fun ChapterScreen() {
20 | Box(
21 | contentAlignment = Alignment.BottomCenter,
22 | modifier = Modifier
23 | .width(width = 375.dp)
24 | .height(height = 812.dp)
25 | .padding(bottom = 37.dp)
26 | .background(color = Color.White)
27 | ) {
28 | Image(
29 | painter = painterResource(id = R.drawable.ic_pause),
30 | contentDescription = "Ellipse 7",
31 | modifier = Modifier
32 | .width(width = 460.dp)
33 | .height(height = 281.dp))
34 | Box(
35 | modifier = Modifier
36 | .size(size = 50.dp)
37 | .background(color = Color(0xff74f823)))
38 | Box(
39 | modifier = Modifier
40 | .size(size = 50.dp)
41 | .background(color = Color(0xff74f823)))
42 | Box(
43 | modifier = Modifier
44 | .size(size = 50.dp)
45 | .background(color = Color(0xffd9d9d9)))
46 | Box(
47 | modifier = Modifier
48 | .size(size = 50.dp)
49 | .background(color = Color(0xffd9d9d9)))
50 | Box(
51 | modifier = Modifier
52 | .size(size = 50.dp)
53 | .background(color = Color(0xffd9d9d9)))
54 | Box(
55 | modifier = Modifier
56 | .size(size = 50.dp)
57 | .background(color = Color(0xffd9d9d9)))
58 | Box(
59 | modifier = Modifier
60 | .size(size = 50.dp)
61 | .background(color = Color(0xffd9d9d9)))
62 | Text(
63 | text = "Introduction",
64 | color = Color.Black,
65 | style = TextStyle(
66 | fontSize = 40.sp,
67 | fontWeight = FontWeight.Bold)
68 | )
69 | Text(
70 | text = "Loreum ipsum",
71 | color = Color.Black,
72 | style = TextStyle(
73 | fontSize = 25.sp,
74 | fontWeight = FontWeight.Medium))
75 | Text(
76 | text = "Loreum ipsum",
77 | color = Color.Black,
78 | style = TextStyle(
79 | fontSize = 25.sp,
80 | fontWeight = FontWeight.Medium))
81 | Text(
82 | text = "Loreum ipsum",
83 | color = Color.Black,
84 | style = TextStyle(
85 | fontSize = 25.sp,
86 | fontWeight = FontWeight.Medium))
87 | Text(
88 | text = "What is ds",
89 | color = Color.Black,
90 | style = TextStyle(
91 | fontSize = 25.sp,
92 | fontWeight = FontWeight.Medium))
93 | Text(
94 | text = "Loreum ipsum",
95 | color = Color.Black,
96 | style = TextStyle(
97 | fontSize = 25.sp,
98 | fontWeight = FontWeight.Medium))
99 | Text(
100 | text = "Loreum ipsum",
101 | color = Color.Black,
102 | style = TextStyle(
103 | fontSize = 25.sp,
104 | fontWeight = FontWeight.Medium))
105 | Text(
106 | text = "Loreum ipsum",
107 | color = Color.Black,
108 | style = TextStyle(
109 | fontSize = 25.sp,
110 | fontWeight = FontWeight.Medium))
111 | }
112 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/composables/dailygoal_screen/DailyGoalScreen.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.composables.dailygoal_screen
2 |
3 | class DailyGoalScreen {
4 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/composables/home_screen/HomeScreen.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.composables.home_screen
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.*
5 | import androidx.compose.material.Text
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.ui.Alignment
8 | import androidx.compose.ui.Modifier
9 | import androidx.compose.ui.graphics.Color
10 | import androidx.compose.ui.text.TextStyle
11 | import androidx.compose.ui.text.font.FontWeight
12 | import androidx.compose.ui.unit.dp
13 | import androidx.compose.ui.unit.sp
14 |
15 | @Composable
16 | fun HomeScreen() {
17 | Box(
18 | contentAlignment = Alignment.BottomCenter,
19 | modifier = Modifier
20 | .width(width = 375.dp)
21 | .height(height = 812.dp)
22 | .padding(start = 15.dp,
23 | end = 23.dp,
24 | top = 44.dp,
25 | bottom = 195.dp)
26 | .background(color = Color.White)
27 | ) {
28 | Component()
29 | Component()
30 | Component()
31 | Component()
32 | Component()
33 | }
34 | }
35 |
36 | @Composable
37 | fun Component() {
38 | Box(
39 | contentAlignment = Alignment.Center,
40 | modifier = Modifier
41 | .width(width = 150.dp)
42 | .height(height = 181.dp)
43 | ) {
44 | Box(
45 | modifier = Modifier
46 | .size(size = 150.dp))
47 | Text(
48 | text = " Tree",
49 | color = Color.Black,
50 | style = TextStyle(
51 | fontSize = 20.sp,
52 | fontWeight = FontWeight.Bold)
53 | )
54 | Box(
55 | modifier = Modifier
56 | .size(size = 100.dp)
57 | .background(color = Color(0xffd9d9d9)))
58 | }
59 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/composables/streak_screen/StreakScreen.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.composables.streak_screen
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.*
6 | import androidx.compose.material.Text
7 | import androidx.compose.runtime.Composable
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.graphics.Color
11 | import androidx.compose.ui.layout.ContentScale
12 | import androidx.compose.ui.res.painterResource
13 | import androidx.compose.ui.text.TextStyle
14 | import androidx.compose.ui.text.font.FontWeight
15 | import androidx.compose.ui.text.style.TextAlign
16 | import androidx.compose.ui.unit.dp
17 | import androidx.compose.ui.unit.sp
18 | import com.dlight.algoguide.R
19 |
20 | @Composable
21 | fun StreakCount() {
22 | Box(
23 | contentAlignment = Alignment.BottomCenter,
24 | modifier = Modifier
25 | .width(width = 375.dp)
26 | .height(height = 812.dp)
27 | .padding(start = 34.dp,
28 | end = 27.dp,
29 | top = 50.dp,
30 | bottom = 64.dp)
31 | .background(color = Color.White)
32 | ) {
33 | Box(
34 | modifier = Modifier
35 | .width(width = 146.dp)
36 | .height(height = 136.dp)
37 | .background(color = Color(0xffd9d9d9)))
38 | Box(
39 | modifier = Modifier
40 | .width(width = 300.dp)
41 | .height(height = 36.dp)
42 | .background(color = Color(0xffd9d9d9)))
43 | Box(
44 | modifier = Modifier
45 | .width(width = 100.dp)
46 | .height(height = 36.dp)
47 | .background(color = Color(0xff74f823)))
48 | Box(
49 | modifier = Modifier
50 | .width(width = 314.dp)
51 | .height(height = 150.dp)
52 | .background(color = Color(0xffd9d9d9)))
53 | Text(
54 | text = "Daily Progress",
55 | color = Color.Black,
56 | style = TextStyle(
57 | fontSize = 24.sp,
58 | fontWeight = FontWeight.Bold)
59 | )
60 | CalendarMonthJanuary()
61 | Text(
62 | text = " 5\n Topics",
63 | color = Color.Black,
64 | style = TextStyle(
65 | fontSize = 24.sp,
66 | fontWeight = FontWeight.Bold))
67 | Image(
68 | painter = painterResource(id = R.drawable.ic_play),
69 | contentDescription = "Open Book",
70 | contentScale = ContentScale.Inside,
71 | modifier = Modifier
72 | .width(width = 96.dp)
73 | .height(height = 50.dp))
74 | Image(
75 | painter = painterResource(id = R.drawable.ic_pause),
76 | contentDescription = "Local fire department",
77 | modifier = Modifier
78 | .size(size = 150.dp))
79 | Text(
80 | text = "20 days",
81 | color = Color.Black,
82 | style = TextStyle(
83 | fontSize = 40.sp,
84 | fontWeight = FontWeight.Bold))
85 | Box(
86 | modifier = Modifier
87 | .width(width = 146.dp)
88 | .height(height = 136.dp)
89 | .background(color = Color(0xffd9d9d9)))
90 | Text(
91 | text = " 10\nChapters",
92 | color = Color.Black,
93 | style = TextStyle(
94 | fontSize = 24.sp,
95 | fontWeight = FontWeight.Bold))
96 | Image(
97 | painter = painterResource(id = R.drawable.ic_pause),
98 | contentDescription = "Paper",
99 | contentScale = ContentScale.Inside,
100 | modifier = Modifier
101 | .width(width = 96.dp)
102 | .height(height = 50.dp))
103 | }
104 | }
105 |
106 | @Composable
107 | fun CalendarMonthJanuary() {
108 | Box(
109 | contentAlignment = Alignment.BottomStart,
110 | modifier = Modifier
111 | .width(width = 284.dp)
112 | .height(height = 230.dp)
113 | .padding(bottom = 20.dp)
114 | ) {
115 | Column(
116 | verticalArrangement = Arrangement.SpaceBetween,
117 | modifier = Modifier
118 | .fillMaxWidth()
119 | .height(height = 120.dp)
120 | ) {
121 | Row(
122 | horizontalArrangement = Arrangement.SpaceBetween,
123 | verticalAlignment = Alignment.CenterVertically,
124 | modifier = Modifier
125 | .width(width = 284.dp)
126 | ) {
127 | repeat(5) {
128 | ItemsWeekDeyWeekendNoActiveYesFillNoStrokNo()
129 | }
130 |
131 | ItemsWeekDeyWeekendYesActiveYesFillNoStrokNo()
132 | ItemsWeekDeyWeekendYesActiveYesFillNoStrokNo()
133 | }
134 | Row(
135 | horizontalArrangement = Arrangement.SpaceBetween,
136 | verticalAlignment = Alignment.CenterVertically,
137 | modifier = Modifier
138 | .width(width = 284.dp)
139 | ) {
140 | repeat(5) {
141 | ItemsNamberDeyWeekendNoActiveNoFillNoStrokNo()
142 | }
143 |
144 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
145 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
146 | }
147 | Row(
148 | horizontalArrangement = Arrangement.SpaceBetween,
149 | verticalAlignment = Alignment.CenterVertically,
150 | modifier = Modifier
151 | .width(width = 284.dp)
152 | ) {
153 | repeat(5) {
154 | ItemsNamberDeyWeekendNoActiveYesFillNoStrokNo()
155 | }
156 |
157 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
158 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
159 | }
160 | Row(
161 | horizontalArrangement = Arrangement.SpaceBetween,
162 | verticalAlignment = Alignment.CenterVertically,
163 | modifier = Modifier
164 | .width(width = 284.dp)
165 | ) {
166 | repeat(5) {
167 | ItemsNamberDeyWeekendNoActiveYesFillNoStrokNo()
168 | }
169 |
170 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
171 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
172 | }
173 | Row(
174 | horizontalArrangement = Arrangement.SpaceBetween,
175 | verticalAlignment = Alignment.CenterVertically,
176 | modifier = Modifier
177 | .width(width = 284.dp)
178 | ) {
179 | repeat(5) {
180 | ItemsNamberDeyWeekendNoActiveYesFillNoStrokNo()
181 | }
182 |
183 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
184 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
185 | }
186 | Row(
187 | horizontalArrangement = Arrangement.SpaceBetween,
188 | verticalAlignment = Alignment.CenterVertically,
189 | modifier = Modifier
190 | .width(width = 284.dp)
191 | ) {
192 | repeat(5) {
193 | ItemsNamberDeyWeekendNoActiveYesFillNoStrokNo()
194 | }
195 |
196 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
197 | ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo()
198 | }
199 | Row(
200 | horizontalArrangement = Arrangement.SpaceBetween,
201 | verticalAlignment = Alignment.CenterVertically,
202 | modifier = Modifier
203 | .width(width = 284.dp)
204 | ) {
205 | repeat(4) {
206 | ItemsNamberDeyWeekendNoActiveNoFillNoStrokNo()
207 | }
208 |
209 | ItemsNamberDeyWeekendYesActiveNoFillNoStrokNo()
210 | ItemsNamberDeyWeekendYesActiveNoFillNoStrokNo()
211 | }
212 | }
213 | }
214 | }
215 |
216 | @Composable
217 | fun ItemsWeekDeyWeekendNoActiveYesFillNoStrokNo() {
218 | Box(
219 | contentAlignment = Alignment.Center,
220 | modifier = Modifier
221 | .size(size = 22.dp)
222 | ) {
223 | Text(
224 | text = "Tu",
225 | color = Color(0xffb3b3b3),
226 | textAlign = TextAlign.Center,
227 | style = TextStyle(
228 | fontSize = 11.sp))
229 | }
230 | }
231 |
232 | @Composable
233 | fun ItemsWeekDeyWeekendYesActiveYesFillNoStrokNo() {
234 | Box(
235 | contentAlignment = Alignment.Center,
236 | modifier = Modifier
237 | .size(size = 22.dp)
238 | ) {
239 | Text(
240 | text = "Su",
241 | color = Color(0xff17a1fa),
242 | textAlign = TextAlign.Center,
243 | style = TextStyle(
244 | fontSize = 11.sp))
245 | }
246 | }
247 |
248 | @Composable
249 | fun ItemsNamberDeyWeekendNoActiveNoFillNoStrokNo() {
250 | Box(
251 | contentAlignment = Alignment.Center,
252 | modifier = Modifier
253 | .size(size = 22.dp)
254 | ) {
255 | Text(
256 | text = "2",
257 | color = Color(0xff616161),
258 | textAlign = TextAlign.Center,
259 | style = TextStyle(
260 | fontSize = 11.sp))
261 | }
262 | }
263 |
264 | @Composable
265 | fun ItemsNamberDeyWeekendYesActiveYesFillNoStrokNo() {
266 | Box(
267 | contentAlignment = Alignment.Center,
268 | modifier = Modifier
269 | .size(size = 22.dp)
270 | ) {
271 | Text(
272 | text = "30",
273 | color = Color(0xff17a1fa),
274 | textAlign = TextAlign.Center,
275 | style = TextStyle(
276 | fontSize = 11.sp))
277 | }
278 | }
279 |
280 | @Composable
281 | fun ItemsNamberDeyWeekendNoActiveYesFillNoStrokNo() {
282 | Box(
283 | contentAlignment = Alignment.Center,
284 | modifier = Modifier
285 | .size(size = 22.dp)
286 | ) {
287 | Text(
288 | text = "25",
289 | color = Color(0xffb3b3b3),
290 | textAlign = TextAlign.Center,
291 | style = TextStyle(
292 | fontSize = 11.sp))
293 | }
294 | }
295 |
296 | @Composable
297 | fun ItemsNamberDeyWeekendYesActiveNoFillNoStrokNo() {
298 | Box(
299 | contentAlignment = Alignment.Center,
300 | modifier = Modifier
301 | .size(size = 22.dp)
302 | ) {
303 | Text(
304 | text = "6",
305 | color = Color(0xff1270b0),
306 | textAlign = TextAlign.Center,
307 | style = TextStyle(
308 | fontSize = 11.sp))
309 | }
310 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/array/Array.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.array
2 |
3 | class Array {
4 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/Longest_Common_Subsequence/lcs.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.Longest_Common_Subsequence
2 |
3 | import java.util.*
4 |
5 | object lcs {
6 | @JvmStatic
7 | fun main(args: Array) {
8 | val s1 = "abcde"
9 | val s2 = "ace"
10 | println("The Length of Longest Common Subsequence is " + longestCommonSubsequence(s1, s2))
11 | }
12 |
13 | private fun longestCommonSubsequence(s1: String, s2: String): Int {
14 | val n = s1.length
15 | val m = s2.length
16 | val dp = Array(n + 1) {
17 | IntArray(
18 | m + 1
19 | )
20 | }
21 | for (rows in dp) {
22 | Arrays.fill(rows, -1)
23 | }
24 | for (i in 0..n) {
25 | dp[i][0] = 0
26 | }
27 | for (i in 0..m) {
28 | dp[0][i] = 0
29 | }
30 | for (ind1 in 0..n) {
31 | for (ind2 in 0..m) {
32 | if (s1[ind1] == s2[ind2]) {
33 | dp[ind1][ind2] = 1 + dp[ind1 - 1][ind2 - 1]
34 | } else {
35 | dp[ind1][ind2] = Math.max(dp[ind1 - 1][ind2], dp[ind1][ind2 - 1])
36 | }
37 | }
38 | }
39 | return dp[n][m]
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/buy_sell_stocks/Buysellstocks.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.buy_sell_stocks
2 |
3 | object buysellstocks {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val prices = intArrayOf(7, 1, 5, 3, 6, 4)
7 | println(maxProfit(prices))
8 | }
9 |
10 | private fun maxProfit(prices: IntArray): Int {
11 | var buy = Int.MAX_VALUE
12 | var maxprofit = 0
13 | for (i in prices.indices) {
14 | buy = Math.min(buy, prices[i])
15 | maxprofit = Math.max(maxprofit, prices[i] - buy)
16 | }
17 | return maxprofit
18 | }
19 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/coin_change/coinchange.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.coin_change
2 |
3 | object CoinChange {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val coins = intArrayOf(1, 2, 5)
7 | val amount = 11
8 | println(coinChange(coins, amount))
9 | }
10 |
11 | private fun coinChange(coins: IntArray, amount: Int): Int {
12 | val dp = IntArray(amount + 1)
13 | for (i in 1 until dp.size) {
14 | dp[i] = dp.size
15 | for (c in coins) {
16 | if (i >= c) {
17 | dp[i] = Math.min(dp[i], dp[i - c] + 1)
18 | }
19 | }
20 | }
21 | return if (dp[amount] == dp.size) -1 else dp[amount]
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/flloyd_warshall_algorithm/FloydWarshall.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.flloyd_warshall_algorithm
2 |
3 |
4 | internal class FloydWarshall {
5 | // Implementing floyd warshall algorithm
6 | fun floydWarshall(graph: Array) {
7 | val matrix = Array(nV) {
8 | IntArray(
9 | nV
10 | )
11 | }
12 | var i: Int
13 | var j: Int
14 | i = 0
15 | while (i < nV) {
16 | j = 0
17 | while (j < nV) {
18 | matrix[i][j] = graph[i][j]
19 | j++
20 | }
21 | i++
22 | }
23 |
24 | // Adding vertices individually
25 | var k: Int = 0
26 | while (k < nV) {
27 | i = 0
28 | while (i < nV) {
29 | j = 0
30 | while (j < nV) {
31 | if (matrix[i][k] + matrix[k][j] < matrix[i][j]) matrix[i][j] =
32 | matrix[i][k] + matrix[k][j]
33 | j++
34 | }
35 | i++
36 | }
37 | k++
38 | }
39 | printMatrix(matrix)
40 | }
41 |
42 | private fun printMatrix(matrix: Array) {
43 | for (i in 0 until nV) {
44 | for (j in 0 until nV) {
45 | if (matrix[i][j] == INF) print("INF ") else print(matrix[i][j].toString() + " ")
46 | }
47 | println()
48 | }
49 | }
50 |
51 | companion object {
52 | const val INF = 9999
53 | const val nV = 4
54 | @JvmStatic
55 | fun main(args: Array) {
56 | val graph = arrayOf(
57 | intArrayOf(0, 3, INF, 5),
58 | intArrayOf(2, 0, INF, 4),
59 | intArrayOf(INF, 1, 0, INF),
60 | intArrayOf(
61 | INF, INF, 2, 0
62 | )
63 | )
64 | val a = FloydWarshall()
65 | a.floydWarshall(graph)
66 | }
67 | }
68 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/house_robber/house_robbers.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.house_robber
2 |
3 | object house_robbers {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val data = intArrayOf(2, 7, 9, 3, 1)
7 | println(rob(data))
8 | }
9 |
10 | fun rob(num: IntArray): Int {
11 | var rob = 0 //max monney can get if rob current house
12 | var notrob = 0 //max money can get if not rob current house
13 | for (i in num.indices) {
14 | val currob = notrob + num[i] //if rob current value, previous house must not be robbed
15 | notrob = Math.max(
16 | notrob,
17 | rob
18 | ) //if not rob ith house, take the max value of robbed (i-1)th house and not rob (i-1)th house
19 | rob = currob
20 | }
21 | return Math.max(rob, notrob)
22 | }
23 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/knapsack_algorithm/Knapsack.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.knapsack_algorithm
2 |
3 | internal object Knapsack {
4 | // A utility function that returns
5 | // maximum of two integers
6 | fun max(a: Int, b: Int): Int {
7 | return if (a > b) a else b
8 | }
9 |
10 | // Returns the maximum value that can
11 | // be put in a knapsack of capacity W
12 | fun knapSack(
13 | W: Int, wt: IntArray,
14 | `val`: IntArray, n: Int
15 | ): Int {
16 | var i: Int
17 | var w: Int
18 | val K = Array(n + 1) {
19 | IntArray(
20 | W + 1
21 | )
22 | }
23 |
24 | // Build table K[][] in bottom up manner
25 | i = 0
26 | while (i <= n) {
27 | w = 0
28 | while (w <= W) {
29 | if (i == 0 || w == 0) K[i][w] = 0 else if (wt[i - 1] <= w) K[i][w] = max(
30 | `val`[i - 1]
31 | + K[i - 1][w - wt[i - 1]],
32 | K[i - 1][w]
33 | ) else K[i][w] = K[i - 1][w]
34 | w++
35 | }
36 | i++
37 | }
38 | return K[n][W]
39 | }
40 |
41 | // Driver code
42 | @JvmStatic
43 | fun main(args: Array) {
44 | val `val` = intArrayOf(60, 100, 120)
45 | val wt = intArrayOf(10, 20, 30)
46 | val W = 50
47 | val n = `val`.size
48 | println(knapSack(W, wt, `val`, n))
49 | }
50 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/pascals_triangle/pascal_triangle.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.pascals_triangle
2 |
3 | object pascal_triangle {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val numRows = 5
7 | println(generate(numRows))
8 | }
9 |
10 | fun generate(numRows: Int): List> {
11 | val res: MutableList> = ArrayList()
12 | var pre: List? = null
13 | for (i in 0 until numRows) {
14 | val row: MutableList = ArrayList()
15 | for (j in 0..i) {
16 | if (j == 0 || j == i) row.add(1) else {
17 | row.add(pre!![j - 1] + pre[j])
18 | }
19 | }
20 | pre = row
21 | res.add(row)
22 | }
23 | return res
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/dynamic_programming/unique_paths/Unique_Paths.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.dynamic_programming.unique_paths
2 |
3 | object Unique_Paths {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val m = 3
7 | val n = 2
8 | println(uniquePaths(m, n))
9 | }
10 |
11 | fun uniquePaths(m: Int, n: Int): Int {
12 | val grid = Array(m) {
13 | IntArray(
14 | n
15 | )
16 | }
17 | for (i in 0 until m) {
18 | for (j in 0 until n) {
19 | if (i == 0 || j == 0) grid[i][j] = 1 else grid[i][j] =
20 | grid[i][j - 1] + grid[i - 1][j]
21 | }
22 | }
23 | return grid[m - 1][n - 1]
24 | }
25 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/Bipartite_Graph/Bipartite_Graph.kt:
--------------------------------------------------------------------------------
1 | import java.util.LinkedList
2 | import kotlin.jvm.JvmStatic
3 |
4 | class Bipartite_Graph internal constructor(var V: Int) {
5 | var al: MutableList>
6 | fun DFS(visited: BooleanArray, arr: IntArray, data: Int, par: Int): Boolean {
7 | visited[data] = true
8 | if (arr[par] == 1) {
9 | arr[data] = 0
10 | } else {
11 | arr[data] = 1
12 | }
13 | for (it in al[data]) {
14 | if (visited[it!!] == false) {
15 | if (DFS(visited, arr, it, data) == false) {
16 | return false
17 | }
18 | } else if (it != par && arr[it] == arr[data]) {
19 | return false
20 | }
21 | }
22 | return true
23 | }
24 |
25 | fun bipartiteGraph(): Boolean {
26 | val visited = BooleanArray(V)
27 | val arr = IntArray(V)
28 | for (i in 0 until V) {
29 | arr[i] = -1
30 | }
31 | for (i in 0 until V) {
32 | if (visited[i] == false) {
33 | arr[i] = 0
34 | if (!DFS(visited, arr, i, i)) {
35 | return false
36 | }
37 | }
38 | }
39 | return true
40 | }
41 |
42 | fun addEdge(i: Int, j: Int) {
43 | al.get(i).add(j)
44 | }
45 |
46 | companion object {
47 | @JvmStatic
48 | fun main(args: Array) {
49 | // TODO Auto-generated method stub
50 | val ob = Bipartite_Graph(10)
51 | ob.addEdge(0, 1)
52 | ob.addEdge(1, 2)
53 | ob.addEdge(3, 4)
54 | ob.addEdge(4, 5)
55 | ob.addEdge(5, 6)
56 | ob.addEdge(6, 8)
57 | ob.addEdge(6, 7)
58 | ob.addEdge(6, 9)
59 | ob.addEdge(9, 5)
60 |
61 | val ans: Boolean = ob.bipartiteGraph()
62 | print("Is Bipartite Graph : $ans")
63 | }
64 | }
65 |
66 | init {
67 | al = mutableListOf(LinkedList())
68 | for (i in 0 until V) {
69 | al.add(i, LinkedList())
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/breadth_first_search/BreadthFirstSearch.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.graph.breadth_first_search
2 |
3 | import java.util.LinkedList
4 | import java.util.Queue
5 |
6 | /**
7 | * BreadthFirstSearch
8 | *
9 | * A class carrying functionality to perform breadth first search
10 | *
11 | * @constructor Creates an instance of the BreadthFirstSearch class
12 | */
13 | class BreadthFirstSearch {
14 | /**
15 | * Function to perform breadth first search
16 | * @param adj Adjacency list of the graph
17 | * @param target Value to be searched in the given graph
18 | * @return true if the target value is found otherwise false
19 | */
20 | fun breadthFirstSearch(adj : List>, target: Int): Boolean {
21 |
22 | // Array depicting whether a node is visited
23 | val visited = BooleanArray(adj.size) { false }
24 |
25 | // Queue to carry out breadth first search
26 | val queue: Queue = LinkedList()
27 |
28 | // Adding the first node 0 to queue and marking it as visited
29 | queue.add(0)
30 | visited[0] = true
31 |
32 | // Carrying out the search until the queue is empty
33 | while (queue.isNotEmpty()) {
34 |
35 | // Getting the element at the front of the queue
36 | val i = queue.remove()
37 |
38 | // If the element is equal to the target, we return true
39 | if (i == target)
40 | return true
41 |
42 | // We add the adjacents of the current node to the queue for further exploration
43 | for (j in adj[i]) {
44 | if (!visited[j]) {
45 | visited[j] = true
46 | queue.add(j)
47 | }
48 | }
49 | }
50 |
51 | // If the target is not found, return false
52 | return false
53 | }
54 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/depth_first_search/DepthFirstSearch.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.graph.depth_first_search
2 |
3 | /**
4 | * DepthFirstSearch
5 | *
6 | * A class carrying functionality to perform depth first search
7 | *
8 | * @constructor Creates an instance of the DepthFirstSearch class
9 | */
10 | class DepthFirstSearch {
11 | /**
12 | * Function to perform depth first search
13 | * @param adj Adjacency list of the graph
14 | * @param target Value to be searched in the given graph
15 | * @return true if the target value is found otherwise false
16 | */
17 | fun depthFirstSearch(adj : List>, target: Int): Boolean {
18 | val visited = BooleanArray(adj.size) { false }
19 | return depthFirstSearch(0, target, adj, visited)
20 | }
21 |
22 | /**
23 | * Helper function for performing depth first search
24 | * @param i The node of graph that is to be explored
25 | * @param target Value to be searched in the given graph
26 | * @param adj Adjacency list of the graph
27 | * @param visited Boolean array used to depict whether a node is visited or not
28 | * @return true if the target value is found otherwise false
29 | */
30 | private fun depthFirstSearch(i: Int, target: Int, adj: List>, visited: BooleanArray): Boolean {
31 |
32 | // Mark the current node as visited
33 | visited[i] = true
34 |
35 | // If the current value is equal to the target, we have found the target so we return true
36 | if(i == target)
37 | return true
38 |
39 | // We explore the nodes adjacent to the current node
40 | for(j in adj[i]) {
41 |
42 | // If the target is found while exploring the adjacent nodes, we return true
43 | if(!visited[j] && depthFirstSearch(j, target, adj, visited))
44 | return true
45 |
46 | }
47 |
48 | // If the target isn't found, we return false
49 | return false
50 | }
51 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/dijkstras_algorithm/DijkstrasAlgorithm.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.graph.dijkstras_algorithm
2 |
3 | import java.util.*
4 |
5 | class Node2 : Comparator {
6 | var edge = 0
7 | private set
8 | var weight = 0
9 | private set
10 |
11 | constructor() {}
12 | constructor(edge: Int, weight: Int) {
13 | this.edge = edge
14 | this.weight = weight
15 | }
16 |
17 | override fun compare(o1: Node2, o2: Node2): Int {
18 | if (o1.weight > o2.weight) {
19 | return 1
20 | } else if (o1.weight < o2.weight) {
21 | return -1
22 | }
23 | return 0
24 | }
25 | }
26 |
27 | class DijkstrasAlgorithm internal constructor(var V: Int) {
28 | var ll: MutableList>
29 | fun dijkstraAlgo(source: Int) {
30 | val arr = IntArray(V)
31 | Arrays.fill(arr, Int.MAX_VALUE)
32 | arr[source] = 0
33 | //Undirected Graph
34 | val pq = PriorityQueue(V, Node2())
35 | pq.add(Node2(source, 0))
36 | //All weights should be positive or else it does not work properly
37 | while (!pq.isEmpty()) {
38 | val curr = pq.poll()
39 | for (it in ll[curr.edge]) {
40 | if (arr[it.edge] > it.weight + arr[curr.edge]) {
41 | arr[it.edge] = it.weight + arr[curr.edge]
42 | pq.add(Node2(it.edge, arr[it.edge]))
43 | }
44 | }
45 | }
46 | for (i in 0 until V) {
47 | if (arr[i] == Int.MAX_VALUE) {
48 | print("INF ")
49 | } else {
50 | print(arr[i].toString() + " ")
51 | }
52 | }
53 | }
54 |
55 | fun addEdge(i: Int, j: Int, w: Int) {
56 | ll[i].add(Node2(j, w))
57 | ll[j].add(Node2(i, w))
58 | }
59 |
60 | companion object {
61 | @JvmStatic
62 | fun main(args: Array) {
63 | // TODO Auto-generated method stub
64 | val ob = DijkstrasAlgorithm(6)
65 | ob.addEdge(0, 1, 5)
66 | ob.addEdge(1, 2, 2)
67 | ob.addEdge(3, 4, 5)
68 | ob.addEdge(3, 2, 6)
69 | ob.addEdge(2, 4, 3)
70 | ob.addEdge(5, 3, 1)
71 | ob.addEdge(1, 5, 3)
72 | val i = 0
73 | print("Shortest Path from $i is : ")
74 | ob.dijkstraAlgo(i)
75 | }
76 | }
77 |
78 | init {
79 | ll = mutableListOf(LinkedList())
80 | for (i in 0 until V) {
81 | ll.add(i, LinkedList())
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/floyds_algorithm/FloydsAlgorithm.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.graph.floyds_algorithm
2 |
3 | import kotlin.jvm.JvmStatic
4 |
5 | class FloydsAlgorithm {
6 | var V = 4
7 | val INF = 99999
8 | companion object{
9 | @JvmStatic
10 | fun main(args: Array) {
11 | // TODO Auto-generated method stub
12 | val ob = FloydsAlgorithm()
13 | val arr = arrayOf(
14 | intArrayOf(0, 3, ob.INF, 7),
15 | intArrayOf(8, 0, 2, ob.INF),
16 | intArrayOf(5, ob.INF, 0, 1),
17 | intArrayOf(2, ob.INF, ob.INF, 0)
18 | )
19 | ob.shortestPath(arr)
20 | }
21 | }
22 |
23 | fun shortestPath(arr: Array) {
24 | for (k in 0 until V) {
25 | for (i in 0 until V) {
26 | for (j in 0 until V) {
27 | if (arr[i][j] > arr[i][k] + arr[k][j]) {
28 | arr[i][j] = arr[i][k] + arr[k][j]
29 | }
30 | }
31 | } //DIRECT AND UNDIRECT GRAPH BOTH APPLICABLE
32 | } //BUT THE WEIGHTS OF EDGES SHOULD BE POSITIVE
33 | for (i in 0 until V) {
34 | print("Shortest Path From $i : ")
35 | for (j in 0 until V) {
36 | if (arr[i][j] == INF) {
37 | print("INF ")
38 | } else {
39 | print(arr[i][j].toString() + " ")
40 | }
41 | }
42 | println()
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/graph/prims_algorithm/PrimsAlgorithm.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.graph.prims_algorithm
2 |
3 | import java.util.LinkedList
4 | import java.util.Arrays
5 | import java.util.Comparator
6 | import java.util.PriorityQueue
7 | import kotlin.jvm.JvmStatic
8 |
9 | class Node4 : Comparator {
10 | var dest = 0
11 | var weight = 0
12 |
13 | constructor() {}
14 | constructor(d: Int, w: Int) {
15 | dest = d
16 | weight = w
17 | }
18 |
19 | override fun compare(o1: Node4, o2: Node4): Int {
20 | // TODO Auto-generated method stub
21 | if (o1.weight > o2.weight) {
22 | return 1
23 | }
24 | return if (o1.weight < o2.weight) {
25 | -1
26 | } else 0
27 | }
28 | }
29 |
30 | class PrimsAlgorithm internal constructor(var V: Int) {
31 | var ll: MutableList>
32 | fun spanningTree(source: Int) {
33 | val key = IntArray(V)
34 | Arrays.fill(key, Int.MAX_VALUE)
35 | val visited = BooleanArray(V)
36 | Arrays.fill(visited, false)
37 | val parent = IntArray(V)
38 | parent[source] = -1
39 | val pq = PriorityQueue(Node4())
40 | pq.add(Node4(source, -1))
41 | while (!pq.isEmpty()) {
42 | val node = pq.poll()
43 | visited[node.dest] = true
44 | for (it in ll[node.dest]) {
45 | if (!visited[it.dest] && key[it.dest] > it.weight) {
46 | pq.add(Node4(it.dest, it.weight))
47 | key[it.dest] = it.weight
48 | parent[it.dest] = node.dest
49 | }
50 | }
51 | }
52 | var sum = 0
53 | for (i in 1 until V) {
54 | sum += key[i]
55 | println(parent[i].toString() + " , " + i + " --> " + key[i])
56 | }
57 | print("Total weight of minimum spanning tree is : $sum")
58 | }
59 |
60 | fun addEdge(i: Int, j: Int, w: Int) {
61 | ll[i].add(Node4(j, w))
62 | ll[j].add(Node4(i, w))
63 | }
64 |
65 | companion object {
66 | @JvmStatic
67 | fun main(args: Array) {
68 | // TODO Auto-generated method stub
69 | val ob = PrimsAlgorithm(6)
70 | ob.addEdge(0, 1, 1)
71 | ob.addEdge(0, 2, 2)
72 | ob.addEdge(1, 2, 3)
73 | ob.addEdge(1, 4, 7)
74 | ob.addEdge(2, 4, 5)
75 | ob.addEdge(2, 3, 3)
76 | ob.addEdge(4, 5, 6)
77 | ob.addEdge(4, 3, 2)
78 | ob.addEdge(3, 5, 4)
79 | val source = 0
80 | ob.spanningTree(source)
81 | //ob.printGraph();
82 | }
83 | }
84 |
85 | init {
86 | ll = mutableListOf(LinkedList())
87 | for (i in 0 until V) {
88 | ll.add(i, LinkedList())
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/hashing/HashMap.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.hashing
2 |
3 | class HashMap() {
4 | var buckets: ArrayList?>
5 | var size // number of entries
6 | = 0
7 | var numBuckets // number of buckets
8 | = 5
9 |
10 | init {
11 | buckets = ArrayList()
12 | for (i in 0 until numBuckets) {
13 | buckets.add(null)
14 | }
15 | }
16 |
17 | private fun getBucketIndex(key: K): Int {
18 | val hashCode = key.hashCode()
19 | return hashCode % numBuckets
20 | }
21 |
22 | fun size(): Int {
23 | return size
24 | }
25 |
26 | fun loadFactor(): Double {
27 | return size.toDouble() / numBuckets
28 | }
29 |
30 | private fun rehash() {
31 | println(
32 | "\nNumber of Entries = " + size + "\nNumber of Buckets = " + numBuckets + "\nLoad Factor = "
33 | + size.toDouble() / numBuckets
34 | )
35 | val temp = buckets
36 | buckets = ArrayList()
37 | for (i in 0 until (2 * numBuckets)) {
38 | buckets.add(null)
39 | }
40 | size = 0
41 | numBuckets *= 2
42 | for (i in 0 until temp.size) {
43 | var curr = temp[i]
44 | while (curr != null) {
45 | val key = curr.key
46 | val value = curr.value
47 | insert(key, value)
48 | curr = curr.next
49 | }
50 | }
51 | }
52 |
53 | fun insert(key: K, value: V) {
54 | val bucketIndex = getBucketIndex(key)
55 | var curr = buckets[bucketIndex] // curr is a pointer which will be used to traverse the
56 | // LinkedList
57 |
58 | // traverse through the LinkedList, if the key is found then update it's value
59 | while (curr != null) {
60 | if ((curr.key == key)) {
61 | curr.value = value
62 | return
63 | }
64 | curr = curr.next
65 | }
66 | // if the control comes here, this means that the key is not present in the Map,
67 | // so we will create a new MapNode
68 | curr = buckets[bucketIndex]
69 | val newElementNode = MapNode(key, value)
70 | newElementNode.next = curr
71 | buckets[bucketIndex] = newElementNode
72 | size++
73 | val loadFactor = size.toDouble() / numBuckets
74 | if (loadFactor > 0.7) rehash()
75 | }
76 |
77 | fun containsKey(key: K): Boolean {
78 | val index = getBucketIndex(key)
79 | var curr = buckets[index] // this is a pointer which will traverse
80 | while (curr != null) {
81 | // here equals method can be override if you want to use your using your own
82 | // class object else Wrapper class like INTEGER, DOUBLE..have their own equals()
83 | if ((curr.key == key)) {
84 | return true
85 | }
86 | curr = curr.next
87 | }
88 | return false
89 | }
90 |
91 | fun getValue(key: K): V? {
92 | val bucketIndex = getBucketIndex(key)
93 | var curr = buckets[bucketIndex] // curr is a pointer which will be used to traverse the
94 | // LinkedList
95 |
96 | // traverse through the LinkedList, if the key is found then return its value
97 | while (curr != null) {
98 | if ((curr.key == key)) {
99 | return curr.value
100 | }
101 | curr = curr.next
102 | }
103 | return null
104 | }
105 |
106 | fun remove(key: K): V? {
107 | val bucketIndex = getBucketIndex(key)
108 | // curr is a pointer which will be used to traverse the LinkedList
109 | var curr = buckets[bucketIndex]
110 | // prev is another pointer which will be used to store the location of the
111 | // previous node
112 | var prev: MapNode? = null
113 |
114 | // traverse through the LinkedList, if the key is found then return its value
115 | while (curr != null) {
116 | if ((curr.key == key)) {
117 | if (prev == null) buckets[bucketIndex] = curr.next else prev.next = curr.next
118 | size--
119 | return curr.value
120 | }
121 | prev = curr
122 | curr = curr.next
123 | }
124 | return null
125 | }
126 |
127 | companion object {
128 | @JvmStatic
129 | fun main(args: Array) {
130 | val map: HashMap = HashMap()
131 | for (i in 1..20) {
132 | map.insert("abc$i", i)
133 | println("For Entry " + i + " LoadFactor = " + map.loadFactor())
134 | }
135 | println(map.containsKey("abc5"))
136 | map.remove("abc8")
137 | map.remove("abc9")
138 | map.remove("abc8")
139 | for (i in 0 until map.size()) {
140 | println("abc" + i + ":" + map.getValue("abc$i"))
141 | }
142 | }
143 | }
144 | }
145 |
146 | class MapNode(var key: K, var value: V) {
147 | var next: MapNode? = null
148 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/linked_list/circular_linked_list/CircularLinkedList.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.linked_list.circular_linked_list
2 | class LinkNode(var data: Int) {
3 | var next: LinkNode ? = null
4 |
5 | }
6 | class CircularLinkedList {
7 | private var head: LinkNode ?
8 | private var tail: LinkNode ?
9 |
10 | init {
11 | this.head = null
12 | this.tail = null
13 | }
14 | // Add node at the end position
15 | fun insert(value: Int) {
16 | val node = LinkNode(value)
17 | if (this.head == null)
18 | {
19 | this.head = node
20 | }
21 | else
22 | {
23 | this.tail?.next = node
24 | }
25 | node.next = this.head
26 | this.tail = node
27 | }
28 | // Display node element of circular linked list
29 | fun display() {
30 | if (this.head == null)
31 | {
32 | println(" Empty Linked List")
33 | }
34 | else
35 | {
36 | print("\n Linked List Element \n")
37 | // First node of linked list
38 | print(" " + this.head?.data)
39 | var temp: LinkNode ? = this.head?.next
40 | // Display linked list node
41 | while (temp != null && temp != this.head)
42 | {
43 | // Display node value
44 | print(" " + temp.data)
45 | // visit to next node
46 | temp = temp.next
47 | }
48 | }
49 | }
50 | fun searchElement(value: Int) {
51 | if (this.head == null)
52 | {
53 | println(" Empty Linked List")
54 | }
55 | else
56 | {
57 | var temp: LinkNode ? = this.head
58 | // Find node
59 | while (temp != null)
60 | {
61 | if (temp.data == value)
62 | {
63 | print("\n Node value $value exist ")
64 | return
65 | }
66 | // Visit to next node
67 | temp = temp.next
68 | if (temp == this.head)
69 | {
70 | // When node are not exist
71 | print("\n Node value $value are not exist ")
72 | return
73 | }
74 | }
75 | }
76 | }
77 | }
78 | fun main() {
79 | val cll = CircularLinkedList()
80 | // First linked list
81 | cll.insert(9)
82 | cll.insert(4)
83 | cll.insert(7)
84 | cll.insert(8)
85 | cll.insert(1)
86 | cll.insert(11)
87 | cll.insert(3)
88 | cll.display()
89 | // Test
90 | cll.searchElement(4)
91 | cll.searchElement(34)
92 | cll.searchElement(11)
93 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/linked_list/doubly_linked_list/DoublyLinkedList.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.linked_list.doubly_linked_list
2 |
3 | import java.util.*
4 |
5 |
6 | object Doubly_Linked_List {
7 | @JvmStatic
8 | fun main(args: Array) {
9 | val sc = Scanner(System.`in`)
10 | val list = Linkedlists()
11 | var flag = true
12 | var valu: Int
13 | var posi = 0
14 | while (flag) {
15 | println()
16 | println("1. Add item to the list at start")
17 | println("2. Add item to the list at last")
18 | println("3. Add item to the list at position")
19 | println("4. Delete First node")
20 | println("5. Delete last node")
21 | println("6. Delete node at position")
22 | println("7. Update node at position")
23 | println("8. Display Backward/Reverse link list")
24 | println("9. View List")
25 | println("10. Exit")
26 | println("Enter Choice")
27 | val choice: Int = sc.nextInt()
28 | when (choice) {
29 | 1 -> {
30 | println("Enter value")
31 | valu = sc.nextInt()
32 | list.insertAtFirst(valu)
33 | }
34 | 2 -> {
35 | println("Enter value")
36 | valu = sc.nextInt()
37 | list.insertAtLast(valu)
38 | }
39 | 3 -> {
40 | println("Enter value")
41 | valu = sc.nextInt()
42 | println("Enter position")
43 | posi = sc.nextInt()
44 | list.insertAtPos(valu, posi)
45 | }
46 | 4 -> list.deleteFirst()
47 | 5 -> list.deleteLast()
48 | 6 -> {
49 | println("Enter position")
50 | posi = sc.nextInt()
51 | list.deleteAtPos(posi)
52 | }
53 | 7 -> {
54 | println("Enter value")
55 | valu = sc.nextInt()
56 | println("Enter position")
57 | posi = sc.nextInt()
58 | list.updateData(valu, posi)
59 | }
60 | 8 -> list.reverseList()
61 | 9 -> list.viewList()
62 | 10 -> flag = false
63 | else -> println("invalid choice")
64 | }
65 | }
66 | }
67 | }
68 |
69 |
70 | internal class Linkedlists {
71 | internal inner class Node {
72 | var data = 0
73 | private var next: Node? = null
74 | private var prev: Node? = null
75 |
76 | fun setNext(n: Node?) {
77 | next = n
78 | }
79 |
80 | fun setPrev(n: Node?) {
81 | prev = n
82 | }
83 |
84 | fun getNext(): Node {
85 | return next!!
86 | }
87 |
88 | fun getPrev(): Node {
89 | return prev!!
90 | }
91 | }
92 |
93 | private var start: Node? = null
94 | var listSize = 0
95 | private set
96 | private var tail: Node? = null
97 |
98 | //reversing link list
99 | fun reverseList() {
100 | if (isEmpty) {
101 | println("Empty List")
102 | return
103 | }
104 | var t = tail
105 | while (t != null) {
106 | print(t.data.toString() + "|___|" + "-->")
107 | t = t.getPrev()
108 | }
109 | print("null")
110 | }
111 |
112 | val isEmpty: Boolean
113 | get() = if (start == null) true else false
114 |
115 | fun viewList() {
116 | if (isEmpty) {
117 | println("Empty List")
118 | return
119 | }
120 | var t = start
121 | while (t != null) {
122 | print(t.data.toString() + "|___|" + "-->")
123 | t = t.getNext()
124 | }
125 | print("null")
126 | }
127 |
128 | fun insertAtFirst(`val`: Int) {
129 | val n: Node = Node()
130 | n.data = `val`
131 | if (isEmpty) tail = n else start!!.setPrev(n)
132 | n.setNext(start)
133 | start = n
134 | listSize++
135 | }
136 |
137 | fun insertAtLast(`val`: Int) {
138 | val t = start
139 | val n: Node = Node()
140 | n.data = `val`
141 | if (t == null) start = n //if list is null
142 | else tail!!.setNext(n)
143 | n.setPrev(tail)
144 | tail = n
145 | listSize++
146 | }
147 |
148 | fun insertAtPos(`val`: Int, pos: Int) {
149 | if (start == null) {
150 | println("Empty list, Try Again")
151 | return
152 | }
153 | var t: Node = start as Node
154 | val n: Node = Node()
155 | n.data = `val`
156 | for (i in 1 until pos - 1) {
157 | t = t.getNext()
158 | }
159 | n.setNext(t.getNext())
160 | t.getNext().setPrev(n)
161 | t.setNext(n)
162 | n.setPrev(t)
163 | listSize++
164 | }
165 |
166 | fun updateData(`val`: Int, pos: Int) {
167 | if (isEmpty || pos > listSize || pos < 1) {
168 | println("Updation not possible")
169 | return
170 | }
171 | var t = start
172 | for (i in 1 until pos) {
173 | t = t!!.getNext()
174 | }
175 | t!!.data = `val`
176 | }
177 |
178 | fun deleteFirst() {
179 | if (start == null) {
180 | println("list is empty")
181 | return
182 | } else {
183 | val t: Node = start as Node
184 | start = start!!.getNext()
185 | t.setNext(null)
186 | t.setPrev(null)
187 | start!!.setPrev(null)
188 | listSize--
189 | }
190 | }
191 |
192 | fun deleteLast() {
193 | if (start == null) {
194 | println("list is empty")
195 | return
196 | } else {
197 | val t = tail
198 | tail = start!!.getPrev()
199 | t!!.setNext(null)
200 | t.setPrev(null)
201 | tail!!.setPrev(null)
202 | listSize--
203 | }
204 | }
205 |
206 | fun deleteAtPos(pos: Int) {
207 | if (isEmpty || pos > listSize || pos < 1) {
208 | println("Deletetion not possible")
209 | return
210 | } else {
211 | var t = start
212 | val t1: Node
213 | for (i in 1 until pos - 1) {
214 | t = t!!.getNext()
215 | }
216 | t1 = t!!.getNext()
217 | t.setNext(t1.getNext())
218 | t1.getNext().setPrev(t)
219 | t1.setNext(null)
220 | t1.setPrev(null)
221 | listSize--
222 | }
223 | }
224 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/linked_list/singly_linked_list/SinglyLinkedList.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.linked_list.singly_linked_list
2 |
3 | class Node(value: T){
4 | var value:T = value
5 | var nextNode: Node? = null
6 | var prev:Node? = null
7 | }
8 | class LinkedList {
9 | private var head:Node? = null
10 |
11 | var isEmpty:Boolean = head == null
12 |
13 | fun first():Node? = head
14 |
15 | fun clear() {
16 | this.head = null
17 | }
18 |
19 | fun last(): Node? {
20 | var node = head
21 | if (node != null){
22 | while (node?.nextNode != null) {
23 | node = node?.nextNode
24 | }
25 | return node
26 | } else {
27 | return null
28 | }
29 | }
30 |
31 | fun append(value: T) {
32 |
33 | var new = Node(value)
34 | var lastNode = this.last()
35 |
36 | if (lastNode != null) {
37 | new.prev = lastNode
38 | lastNode.nextNode = new
39 | } else {
40 | head = new
41 | }
42 | }
43 |
44 | fun removeNode(node: Node):T {
45 | val prev = node.prev
46 |
47 | val nextNode = node.nextNode
48 | if (prev != null) {
49 | prev.nextNode = nextNode
50 | } else {
51 | head = nextNode
52 | }
53 | nextNode?.prev = prev
54 | node.prev = null
55 | node.nextNode = null
56 | return node.value
57 | }
58 | fun removeLast() : T? {
59 | val last = this.last()
60 | if (last != null) {
61 | return removeNode(last)
62 | } else {
63 | return null
64 | }
65 | }
66 |
67 | override fun toString(): String {
68 | var s = ""
69 | var node = head
70 | while (node != null) {
71 | s += "${node.value}"
72 | node = node.nextNode
73 | if (node != null) { s += " -> " }
74 | }
75 | return s
76 | }
77 | }
78 | fun main() {
79 | var LinkedList = LinkedList()
80 | LinkedList.append("Ruchit")
81 | LinkedList.append("Pokhrel")
82 | LinkedList.append("Kumar")
83 | LinkedList.append("Rathode")
84 | LinkedList.append("Singh")
85 | LinkedList.append("Rajput")
86 | println(LinkedList)
87 |
88 | LinkedList.clear()
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/queues/circular_queue/CircularQueue.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.queues.circular_queue
2 |
3 | const val DEFAULT_CAPACITY2 = 10
4 |
5 | class CircularQueue (size: Int?) {
6 |
7 | private val maxCapacity = size ?: DEFAULT_CAPACITY2
8 | private var itemsCount = 0
9 | private val queue = IntArray(maxCapacity)
10 | private var last = -1
11 | private var first = -1
12 |
13 |
14 | fun enqueue(value: Int): Boolean {
15 | if (isFull()){
16 | print("queue is full")
17 | return false
18 | }
19 |
20 | itemsCount++
21 | if (first == -1){
22 | first = 0
23 | }
24 | last = (last + 1) % maxCapacity
25 | queue[last] = value
26 | return true
27 | }
28 |
29 |
30 | fun dequeue(): Int? {
31 | if (isEmpty()) {
32 | print("queue is empty")
33 | return null
34 | }
35 |
36 | val itemToReturn = queue[first]
37 |
38 | if (first == last) {
39 | first = -1;
40 | last = -1;
41 | }
42 | else{
43 | first = (first + 1) % maxCapacity
44 | }
45 | println("item deleted:"+ itemToReturn)
46 | itemsCount--
47 | return itemToReturn
48 | }
49 |
50 | fun printQueue():Boolean{
51 |
52 | if (isEmpty()) {
53 | print("queue is empty")
54 | return false
55 | }
56 |
57 | println("Elements of queue are:")
58 | var x = first
59 | while(x!=last) {
60 | println(queue[x])
61 | x = (x+1) % maxCapacity
62 | }
63 | println(queue[x])
64 |
65 | return true
66 | }
67 |
68 |
69 | fun peekFirst(): String = queue[first].toString()
70 |
71 | fun peekLast(): String = queue[last].toString()
72 |
73 | fun getSize(): Int = itemsCount
74 |
75 | private fun isFull(): Boolean{
76 | if ((first == last + 1) || (first == 0 && last == maxCapacity - 1)){
77 | return true
78 | }
79 |
80 | return false
81 | }
82 |
83 | private fun isEmpty(): Boolean {
84 | if (first == -1){
85 | return true
86 | }
87 | return false
88 | }
89 | }
90 |
91 | fun main(){
92 |
93 | //pass the size of the queue
94 | var q = CircularQueue(4)
95 |
96 | q.enqueue(7)
97 | q.enqueue(10)
98 | q.enqueue(50)
99 | q.enqueue(16)
100 | q.dequeue()
101 | q.dequeue()
102 | q.enqueue(1)
103 | q.enqueue(2)
104 | q.dequeue()
105 | q.printQueue()
106 |
107 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/queues/deque/Deque.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.queues
2 | import java.util.Deque
3 | import java.util.LinkedList
4 |
5 | //over here we'll be using built-in func to perform deque operations
6 | fun main() {
7 |
8 | val studentQueue: Deque = LinkedList(mutableListOf("Agni", "Bob", "Chris", "David", "Emily"))
9 |
10 | //adds at the end of the queue
11 | studentQueue.add("Felix")
12 |
13 | //adds at the start of the queue
14 | studentQueue.addFirst("Afra")
15 |
16 | //adds at the end of the queue
17 | studentQueue.addLast("Geek")
18 |
19 | //prints the queue
20 | println("queue:" +studentQueue)
21 |
22 | //removes element at the first
23 | val removeFirst = studentQueue.removeFirst()
24 | println("elem removed:" +removeFirst)
25 |
26 | //removes element at the end
27 | val removeLast = studentQueue.removeLast()
28 | println("elem removed:" +removeLast)
29 |
30 | //to get the element
31 | val res = studentQueue.peek()
32 | println(res + " : " +studentQueue)
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/queues/priority_queue/PriorityQueue.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.queues.priority_queue
2 |
3 | var size:Int =0
4 |
5 | class PriorityQueue(){
6 |
7 | // Function to heapify the tree
8 | fun heapify(array: IntArray , size:Int, i:Int):Boolean {
9 | if (size == 1) {
10 | println("Single element in the heap")
11 | }
12 | else {
13 | // Find the largest among root, left child and right child
14 | var largest = i
15 | var l = 2 * i + 1
16 | var r = 2 * i + 2
17 | if (l < size && array[l] > array[largest]){
18 | largest = l
19 | }
20 | if (r < size && array[r] > array[largest]){
21 | largest = r
22 | }
23 |
24 | // Swap and continue heapifying if root is not largest
25 | if (largest != i) {
26 | array[i] = array[largest].also { array[largest] = array[i] }
27 | heapify(array, size, largest)
28 | }
29 | }
30 | return true
31 | }
32 |
33 | // Function to insert an element into the tree
34 | fun insert(array: IntArray,newNum: Int): Boolean {
35 | if (size == 0) {
36 | array[0] = newNum
37 | size += 1
38 | }
39 | else {
40 | array[size] = newNum;
41 | size += 1
42 | var x = size /2-1
43 | while(x >= 0){
44 | heapify(array, size, x)
45 | x -= 1
46 | }
47 | }
48 |
49 | return true
50 | }
51 |
52 | // Function to delete an element from the tree
53 | fun deleteRoot(array: IntArray,num: Int):Boolean {
54 | var y:Int = 0
55 | while(y< size){
56 | if (num == array[y])
57 | break
58 | y += 1
59 | }
60 |
61 | array[y] = array[size - 1].also { array[size - 1] = array[y] }
62 |
63 | size -= 1;
64 |
65 | y= size /2-1
66 | while(y>=0){
67 | heapify(array, size, y);
68 | y -= 1
69 | }
70 | return true
71 | }
72 |
73 | // Print the array
74 | fun printArray(array: IntArray,size:Int):Boolean {
75 |
76 | var z=0
77 | while(z < size){
78 | println(array[z])
79 | z += 1
80 | }
81 | return true
82 | }
83 |
84 | }
85 |
86 | fun main(){
87 |
88 | var p = PriorityQueue()
89 | val array = IntArray(10)
90 |
91 | p.insert(array, 3)
92 | p.insert(array, 3)
93 | p.insert(array, 4)
94 | p.insert(array, 9)
95 | p.insert(array, 5)
96 | p.insert(array, 2)
97 |
98 | println("Max-Heap array: ")
99 | p.printArray(array, size)
100 |
101 | p.deleteRoot(array, 4)
102 |
103 | println("After deleting an element: ")
104 |
105 | p.printArray(array, size)
106 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/queues/queue/Queue.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.queues.queue
2 |
3 | const val DEFAULT_CAPACITY = 10
4 |
5 | class Queue (size: Int?) {
6 |
7 | private val maxCapacity = size ?: DEFAULT_CAPACITY
8 | private var itemsCount = 0
9 | private val queue = IntArray(maxCapacity)
10 | private var last = -1
11 | private var first = 0
12 |
13 |
14 | fun enqueue(value: Int): Boolean {
15 | if (isFull()){
16 | print("queue is full")
17 | return false
18 | }
19 |
20 | itemsCount++
21 |
22 | last = (last + 1) % maxCapacity
23 | queue[last] = value
24 | return true
25 | }
26 |
27 |
28 | fun dequeue(): Int? {
29 | if (isEmpty()) {
30 | print("queue is empty")
31 | return null
32 | }
33 |
34 | //println("item removed:" + queue[first])
35 | val itemToReturn = queue[first]
36 | first = (first + 1) % maxCapacity
37 |
38 | itemsCount--
39 |
40 | return itemToReturn
41 | }
42 |
43 | fun printQueue():Boolean{
44 |
45 | println("Elements of queue are:")
46 | for (i in first..queue.size-1){
47 | println(queue[i])
48 | }
49 |
50 | return true
51 | }
52 |
53 |
54 | fun peekFirst(): String = queue[first].toString()
55 |
56 | fun peekLast(): String = queue[last].toString()
57 |
58 | fun getSize(): Int = itemsCount
59 |
60 | private fun isFull(): Boolean = itemsCount == maxCapacity
61 |
62 | private fun isEmpty(): Boolean = itemsCount == 0
63 | }
64 |
65 | fun main(){
66 |
67 | //pass the size of the queue
68 | var q = Queue(4)
69 |
70 | q.enqueue(7)
71 | q.enqueue(10)
72 | q.enqueue(50)
73 | q.enqueue(16)
74 | print(q.peekFirst())
75 | q.dequeue()
76 | q.dequeue()
77 | q.printQueue()
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/recursion/Recursion.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.recursion
2 |
3 | class Recursion {
4 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/searching/binary_search/BinarySearch.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.searching.binary_search
2 |
3 | /**
4 | * BinarySearch
5 | *
6 | * A class carrying functionality to perform binary search
7 | *
8 | * @constructor Creates an instance of the BinarySearch class
9 | */
10 | class BinarySearch {
11 | /**
12 | * Function to perform binary search
13 | * @param arr Integer array on which binary search is to be performed
14 | * @param target Value to be searched in the given array
15 | * @return index of the target value in the given array, or -1 if it isn't found
16 | */
17 | suspend fun binarySearch(arr: IntArray, target: Int) : Int {
18 | // Initially setting l to the start of the array and r to the end of the array
19 | var l = 0
20 | var r = arr.size - 1
21 |
22 | while(l <= r) {
23 |
24 | // Calculating the middle index
25 | val mid = l + (r - l) / 2
26 |
27 | // If the value at the middle index is equal to the target, we return the index
28 | if (arr[mid] == target)
29 | return mid
30 | // If it is greater than the target, then target can't lie on the right half, so we move to the left half
31 | else if(arr[mid] > target)
32 | r = mid - 1
33 | // If it is less than the target, then target can't lie on the left half, so we move to the right half
34 | else
35 | l = mid + 1
36 | }
37 |
38 | // If the target wasn't found in the given array, return -1
39 | return -1
40 | }
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/searching/linear_search/LinearSearch.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.searching.linear_search
2 |
3 | class LinearSearch {
4 | suspend fun linearSearch(arr: IntArray, target: Int, isFound: (Boolean) -> Unit){
5 | /*Finding element in the array while iterating over the array if found then break */
6 | for(i in arr){
7 | if(i == target) {
8 | isFound(true)
9 | break
10 | }
11 | isFound(false)
12 | }
13 | }
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/Events.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting
2 |
3 | sealed class Events {
4 | object speedUp : Events()
5 | object slowDown : Events()
6 | object playPause : Events()
7 | object previous : Events()
8 | object next : Events()
9 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/SortViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting
2 |
3 | import androidx.compose.runtime.mutableStateOf
4 | import androidx.lifecycle.ViewModel
5 | import androidx.lifecycle.viewModelScope
6 | import com.dlight.algoguide.dsa.sorting.insertion_sort.InsertionSort
7 | import kotlinx.coroutines.delay
8 | import kotlinx.coroutines.launch
9 |
10 | class SortViewModel(
11 | private val insertionSort: InsertionSort
12 | ) : ViewModel() {
13 |
14 | var arr = mutableStateOf(
15 | intArrayOf(
16 | 345, 167, 188, 276, 123, 375, 180, 120,240, 37, 173, 156
17 | )
18 | )
19 | val sortingStart = mutableStateOf(false)
20 | val sortFinish = mutableStateOf(false)
21 | private var sortDelay = 300L
22 | private var pause = false
23 | private var next = 1
24 | private var previous = 0
25 |
26 | private var sortLevels = mutableListOf>()
27 |
28 | init {
29 | viewModelScope.launch {
30 | insertionSort.insertionSort(
31 | arr.value.clone()
32 | ) { modifyArray ->
33 | sortLevels.add(modifyArray.toMutableList())
34 | }
35 | }
36 | }
37 |
38 |
39 | fun onEvent(event: Events) {
40 | when (event) {
41 | is Events.playPause -> {
42 | playPauseAlgorithm()
43 | }
44 | is Events.slowDown -> {
45 | slowDowns()
46 | }
47 | is Events.speedUp -> {
48 | speedUps()
49 | }
50 | is Events.previous -> {
51 | previouss()
52 | }
53 | is Events.next -> {
54 | nexts()
55 | }
56 | }
57 | }
58 |
59 | private fun nexts() {
60 | if (next < sortLevels.size) {
61 | arr.value = sortLevels[next].toIntArray()
62 | next++
63 | previous++
64 | }
65 | }
66 |
67 | private fun previouss() {
68 | if (previous >= 0) {
69 | arr.value = sortLevels[previous].toIntArray()
70 | next--
71 | previous--
72 |
73 | }
74 | }
75 |
76 | private fun speedUps() {
77 | sortDelay += 100
78 | }
79 |
80 | private fun slowDowns() {
81 | if (sortDelay >= 150L) {
82 | sortDelay -= 50
83 | }
84 | }
85 |
86 | private fun playPauseAlgorithm() {
87 |
88 | if (sortingStart.value)
89 | pause()
90 | else
91 | play()
92 |
93 | }
94 |
95 | private var sortingState = 0
96 | private fun play() = viewModelScope.launch{
97 |
98 | pause = false
99 | for (i in sortingState until sortLevels.size) {
100 | if (!pause) {
101 | delay(sortDelay)
102 | arr.value = sortLevels[i].toIntArray()
103 | } else {
104 | sortingState = i
105 | next = i + 1
106 | previous = i
107 | return@launch
108 | }
109 | }
110 |
111 | sortFinish.value = true
112 | }
113 |
114 | private fun pause() {
115 | pause = true
116 | }
117 |
118 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/SortingViewModelProvider.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.ViewModelProvider
5 | import com.dlight.algoguide.dsa.sorting.insertion_sort.InsertionSort
6 |
7 | /**
8 | * Algorithm view model provider
9 | *
10 | * @property insertionSort
11 | * @constructor Create empty Algorithm view model provider
12 | */
13 | class SortingViewModelProvider(
14 | private var insertionSort: InsertionSort
15 | ) : ViewModelProvider.Factory {
16 | override fun create(modelClass: Class): T {
17 | return SortViewModel(insertionSort) as T
18 | }
19 |
20 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/bubble_sort/BubbleSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.bubble_sort
2 |
3 | /**
4 | * BubbleSort
5 | *
6 | * A class carrying functionality to perform bubble sort
7 | *
8 | * @constructor Creates an instance of the BubbleSort class
9 | */
10 |
11 |
12 | class BubbleSort {
13 | suspend fun bubbleSort(
14 | arr: IntArray
15 | ) {
16 | /*Iterating over the whole array */
17 | while (1 < arr.size) {
18 | /*Keeping one bool variable and checking if the whole array is sorted or not*/
19 | var swap = true
20 | while (swap) {
21 | /*Initially keeping swap as false */
22 | swap = false
23 | /*Iterating over the whole array */
24 | for (i in 0 until arr.size - 1) {
25 | /*If the adjacent element is greater then the previous element then perform the
26 | swapping between those 2 numbers */
27 | if (arr[i] > arr[i + 1]) {
28 | /*SWAPING CODE IS THIS */
29 | val temp = arr[i]
30 | arr[i] = arr[i + 1]
31 | arr[i + 1] = temp
32 | }
33 | }
34 | }
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/bubble_sort/domain/model/SortModel.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.bubble_sort.domain.model
2 |
3 | data class SortModel(
4 | val currentItem: Int,
5 | val shouldSwap: Boolean,
6 | val hasNoEffect: Boolean
7 | )
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/bubble_sort/domain/use_cases/BubbleSortUseCase.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.bubble_sort.domain.use_cases
2 |
3 | import com.dlight.algoguide.dsa.sorting.bubble_sort.domain.model.SortModel
4 | import kotlinx.coroutines.flow.Flow
5 | import kotlinx.coroutines.flow.flow
6 |
7 | class BubbleSortUseCase {
8 |
9 | operator fun invoke(list: MutableList): Flow = flow {
10 | var listSizeToCompare = list.size - 1
11 | while (listSizeToCompare > 1) {
12 | var innerIterator = 0
13 | while (innerIterator < listSizeToCompare) {
14 | val currentListItem = list[innerIterator]
15 | val nextListItem = list[innerIterator + 1]
16 | emit(
17 | SortModel(
18 | currentItem = innerIterator,
19 | shouldSwap = false,
20 | hasNoEffect = false
21 | )
22 | )
23 | kotlinx.coroutines.delay(500)
24 | if (currentListItem > nextListItem) {
25 | list.swap(innerIterator, innerIterator + 1)
26 | emit(
27 | SortModel(
28 | currentItem = innerIterator,
29 | shouldSwap = true,
30 | hasNoEffect = false
31 | )
32 | )
33 | } else {
34 | SortModel(currentItem = innerIterator, shouldSwap = false, hasNoEffect = true)
35 | }
36 | kotlinx.coroutines.delay(500)
37 | innerIterator++
38 | }
39 | listSizeToCompare--
40 | }
41 | }
42 | }
43 |
44 | private fun MutableList.swap(indexOne: Int, indexTwo: Int) {
45 | val tempOne = this[indexOne]
46 | this[indexOne] = this[indexTwo]
47 | this[indexTwo] = tempOne
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/bubble_sort/presentation/BubbleSortViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.bubble_sort.presentation
2 |
3 | import androidx.compose.runtime.*
4 | import androidx.compose.ui.graphics.Color
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import com.dlight.algoguide.dsa.sorting.bubble_sort.domain.use_cases.BubbleSortUseCase
8 | import com.dlight.algoguide.dsa.sorting.bubble_sort.presentation.state.ListUiItem
9 | import kotlinx.coroutines.flow.collect
10 | import kotlinx.coroutines.launch
11 | import java.util.*
12 |
13 | class BubbleSortViewModel(
14 | private val bubbleSortUseCase: BubbleSortUseCase = BubbleSortUseCase()
15 | ) : ViewModel() {
16 |
17 | var listToSort = mutableStateListOf()
18 |
19 | init {
20 | for (i in 0 until 9) {
21 | val rnd = Random()
22 | listToSort.add(
23 | ListUiItem(
24 | id = i,
25 | isCurrentlyCompared = false,
26 | value = rnd.nextInt(150),
27 | color = Color(
28 | 255,
29 | rnd.nextInt(256),
30 | rnd.nextInt(256),
31 | 255
32 | )
33 | )
34 | )
35 | }
36 | }
37 |
38 | fun startSorting() {
39 | viewModelScope.launch {
40 | bubbleSortUseCase(listToSort.map { listUiItem ->
41 | listUiItem.value
42 | }.toMutableList()).collect { swapInfo ->
43 | val currentItemIndex = swapInfo.currentItem
44 | listToSort[currentItemIndex] =
45 | listToSort[currentItemIndex].copy(isCurrentlyCompared = true)
46 | listToSort[currentItemIndex + 1] =
47 | listToSort[currentItemIndex + 1].copy(isCurrentlyCompared = true)
48 |
49 | if (swapInfo.shouldSwap) {
50 | val firstItem = listToSort[currentItemIndex].copy(isCurrentlyCompared = false)
51 | listToSort[currentItemIndex] =
52 | listToSort[currentItemIndex + 1].copy(isCurrentlyCompared = false)
53 | listToSort[currentItemIndex + 1] = firstItem
54 | }
55 |
56 | if (swapInfo.hasNoEffect) {
57 | listToSort[currentItemIndex] =
58 | listToSort[currentItemIndex].copy(isCurrentlyCompared = false)
59 | listToSort[currentItemIndex + 1] =
60 | listToSort[currentItemIndex + 1].copy(isCurrentlyCompared = false)
61 | }
62 | }
63 | }
64 | }
65 | }
66 |
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/bubble_sort/presentation/state/ListUiItem.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.bubble_sort.presentation.state
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | data class ListUiItem(
6 | val id: Int,
7 | val isCurrentlyCompared: Boolean,
8 | val value: Int,
9 | val color: Color
10 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/composables/VisualizerBottomBar.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.composables
2 |
3 | import androidx.compose.foundation.layout.Arrangement
4 | import androidx.compose.foundation.layout.Row
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.material.BottomAppBar
7 | import androidx.compose.material.Icon
8 | import androidx.compose.material.IconButton
9 | import androidx.compose.material.MaterialTheme
10 | import androidx.compose.material.icons.Icons
11 | import androidx.compose.material.icons.filled.Add
12 | import androidx.compose.material.icons.filled.ArrowBack
13 | import androidx.compose.material.icons.filled.ArrowForward
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.ui.Alignment
16 | import androidx.compose.ui.Modifier
17 | import androidx.compose.ui.res.painterResource
18 | import com.dlight.algoguide.R
19 |
20 | @Composable
21 | fun VisualizerBottomBar(
22 | modifier: Modifier = Modifier,
23 | playPauseClick: () -> Unit,
24 | slowDownClick: () -> Unit,
25 | speedUpClick: () -> Unit,
26 | previousClick: () -> Unit,
27 | nextClick: () -> Unit,
28 | isPlaying: Boolean = false
29 | ) {
30 | BottomAppBar(
31 | modifier = modifier,
32 | backgroundColor = MaterialTheme.colors.surface
33 | ) {
34 | Row(
35 | modifier = modifier.fillMaxWidth(),
36 | verticalAlignment = Alignment.CenterVertically,
37 | horizontalArrangement = Arrangement.SpaceEvenly
38 | ) {
39 | IconButton(onClick = slowDownClick) {
40 | Icon(
41 | painter = painterResource(id = R.drawable.ic_slow),
42 | contentDescription = "Slow down",
43 | tint = MaterialTheme.colors.onSurface
44 | )
45 | }
46 |
47 | IconButton(onClick = playPauseClick) {
48 | Icon(
49 | painter = painterResource(
50 | id = if (!isPlaying) R.drawable.ic_play else R.drawable.ic_pause
51 | ),
52 | contentDescription = "Play Pause",
53 | tint = MaterialTheme.colors.onSurface
54 | )
55 | }
56 |
57 | IconButton(onClick = speedUpClick) {
58 | Icon(
59 | imageVector = Icons.Default.Add,
60 | contentDescription = "Speed Up",
61 | tint = MaterialTheme.colors.onSurface
62 | )
63 | }
64 |
65 | IconButton(onClick = previousClick) {
66 | Icon(
67 | imageVector = Icons.Default.ArrowBack,
68 | contentDescription = "Previous",
69 | tint = MaterialTheme.colors.onSurface
70 | )
71 | }
72 |
73 | IconButton(onClick = nextClick) {
74 | Icon(
75 | imageVector = Icons.Default.ArrowForward,
76 | contentDescription = "next",
77 | tint = MaterialTheme.colors.onSurface
78 | )
79 | }
80 |
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/composables/VisualizerSection.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.composables
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.*
5 | import androidx.compose.material.MaterialTheme
6 | import androidx.compose.runtime.Composable
7 | import androidx.compose.runtime.remember
8 | import androidx.compose.ui.Alignment
9 | import androidx.compose.ui.Modifier
10 | import androidx.compose.ui.unit.dp
11 |
12 | @Composable
13 | fun VisualizerSection(
14 | modifier: Modifier = Modifier,
15 | arr: IntArray
16 | ) {
17 | BoxWithConstraints(
18 | modifier = modifier.fillMaxWidth(),
19 | contentAlignment = Alignment.BottomCenter
20 | ) {
21 | val maxHeight = maxHeight - 75.dp
22 | val itemWidth = remember {
23 | maxWidth / arr.size - 2.dp
24 | }
25 |
26 | Row(
27 | modifier = modifier,
28 | horizontalArrangement = Arrangement.SpaceEvenly,
29 | verticalAlignment = Alignment.Bottom,
30 | ) {
31 | arr.forEach {
32 | Box(
33 | modifier = modifier
34 | .height(if (it.dp > maxHeight) maxHeight else it.dp)
35 | .width(itemWidth)
36 | .background(MaterialTheme.colors.onBackground)
37 | )
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/counting_sort/CountingSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.counting_sort
2 |
3 | class CountingSort{
4 | fun countingSort(A: Array, max: Int) {
5 | // Array in which result will store
6 | var b = Array(A.size) { 0 }
7 | // count array
8 | var c = Array(max) { 0 }
9 | for (i in A.indices) {
10 | //count the no. of occurrence of a
11 | //particular element store in count array
12 | c[A[i] - 1] = c[A[i] - 1] + 1
13 | }
14 | for (i in 1 until c.size) {
15 | // calculate commutative sum
16 | c[i] = c[i] + c[i - 1]
17 | }
18 | for (i in A.size - 1 downTo 0) {
19 | // place the element at its position
20 | b[c[A[i] - 1] - 1] = A[i]
21 | // decrease the occurrence of the element by 1
22 | c[A[i] - 1] = c[A[i] - 1] - 1
23 | }
24 | println("After sorting :")
25 | for (i in b) {
26 | print("$i ")
27 | }
28 |
29 | }
30 | }
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/heap_sort/HeapSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.heap_sort
2 |
3 | class HeapSort {
4 |
5 | var heapSize = 0
6 |
7 | fun heapSort(arr: Array) {
8 | buildMaxHeap(arr)
9 | }
10 |
11 | private fun buildMaxHeap(arr: Array) {
12 | heapSize = arr.size
13 | for (i in heapSize / 2 downTo 0)
14 | max_heapify(arr,i)
15 | }
16 |
17 | private fun max_heapify(arr: Array, i: Int) {
18 | var left = left(i)
19 | var right = right(i)
20 | var largest: Int
21 |
22 | if ((left <= heapSize - 1) && (arr[left] > arr[right]))
23 | largest = left
24 | else
25 | largest = i
26 | if ((right <= heapSize - 1) && (arr[right] > arr[left]))
27 | largest = right
28 | if (largest != i) {
29 | swap(arr, i, largest)
30 | max_heapify(arr, largest)
31 | }
32 | }
33 |
34 | private fun swap(arr: Array, i: Int, largest: Int) {
35 | var temp = arr[i]
36 | arr[i] = arr[largest]
37 | arr[largest] = temp
38 | }
39 |
40 | private fun right(i: Int): Int {
41 | return 2 * i + 1
42 | }
43 |
44 | private fun left(i: Int): Int {
45 | return 2 * i
46 | }
47 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/insertion_sort/InsertionSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.insertion_sort
2 |
3 | /**
4 | * Insertion sort
5 | *
6 | * @constructor Create empty Insertion sort
7 | */
8 | class InsertionSort {
9 | suspend fun insertionSort(
10 | arr: IntArray,
11 | swap: (IntArray) -> Unit
12 | ) {
13 | /* Iterating over the whole array */
14 | for (i in 1 until arr.size)
15 | {
16 | val key = arr[i - 1]
17 | var j = i - 1
18 | while (j >= 0 && key < arr[j]) {
19 | /*
20 | Move elements of arr[0..i-1],
21 | that are greater than key, to one
22 | position ahead of their
23 | current position
24 | */
25 | arr [j + 1] = arr[j]
26 | swap(arr)
27 | j--
28 | }
29 | arr[j + 1] = key
30 | swap(arr)
31 | }
32 | }
33 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/merge_sort/MergeSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.merge_sort
2 | /**
3 | * Insertion sort
4 | *
5 | * @constructor Create empty Insertion sort
6 | */
7 | class MergeSort {
8 | suspend fun mergeSort(
9 | arr: List
10 | ): List {
11 | /*Function which returns an int array
12 | Calculating the mid point
13 | left of the array
14 | and right of the array
15 | */
16 | val middle = arr.size / 2
17 | var left = arr.subList(0, middle)
18 | var right = arr.subList(middle, arr.size)
19 | /*Calling merge function recursively to merge the array */
20 | return merge(mergeSort(left), mergeSort(right))
21 | }
22 |
23 | private fun merge(left: List, right: List): List {
24 | var indexLeft = 0
25 | var indexRight = 0
26 | var newList: MutableList = mutableListOf()
27 | /*Copying the elements of the array into the new list into
28 | a sorted form*/
29 | while (indexLeft < left.count() && indexRight < right.count()) {
30 | if (left[indexLeft] <= right[indexRight]) {
31 | newList.add(left[indexLeft])
32 | indexLeft++
33 | } else {
34 | newList.add(right[indexRight])
35 | indexRight++
36 | }
37 | }
38 | /*If any element left in the array belonging to either right or left side of array then
39 | insert into the array */
40 | //THIS THE LEFT SIDE
41 | while (indexLeft < left.size) {
42 | newList.add(left[indexLeft])
43 | indexLeft++
44 | }
45 | //THIS IS THE RIGHT SIDE OF THE ARRAY
46 | while (indexRight < right.size) {
47 | newList.add(right[indexRight])
48 | indexRight++
49 | }
50 | return newList
51 | }
52 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/quick_sort/QuickSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.quick_sort
2 |
3 | /**
4 | * Quick sort
5 | *
6 | * @constructor Create empty Quick sort
7 | */
8 | class QuickSort {
9 | suspend fun quickSort(
10 | arr: IntArray, left: Int, right: Int) {
11 | /*First finding the partioning index using thepartion function */
12 | val index = partition (arr, left, right)
13 | if (left < index - 1)
14 | /*checking for better position left or right then performing thr sort*/
15 | quickSort(arr, left, index - 1)
16 | if (index < right )
17 | quickSort(arr, index, right)
18 | }
19 | /* This function takes last element as pivot, places
20 | the pivot element at its correct position in sorted
21 | array, and places all smaller (smaller than pivot)
22 | to left of pivot and all greater elements to right
23 | of pivot */
24 | private fun partition(arr: IntArray, left: Int, right: Int): Int {
25 | var left = left
26 | var right = right
27 | /* Pivot point */
28 | val pivot = arr[(left + right) / 2]
29 | while (left <= right) {
30 | while (arr[left] < pivot) left++
31 | while (arr[right] > pivot) right--
32 | if (left <= right) {
33 | swap(arr, left, right)
34 | left++
35 | right--
36 | }
37 | }
38 | return left
39 | }
40 | /*Swap function that helps in swaping the numbers */
41 | private fun swap(arr: IntArray, left: Int, right: Int) {
42 | val temp = arr [left]
43 | arr[left] = arr[right]
44 | arr[right] = temp
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/radix_sort/RadixSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.radix_sort
2 |
3 | class RadixSort {
4 | fun IntArray.radixSort(): IntArray {
5 | var result = this
6 | val max = getMax()
7 |
8 | var place = 1
9 | while (max / place > 0) {
10 | result = result.countingSort(place)
11 | place *= 10
12 | }
13 |
14 | return result
15 | }
16 |
17 | private fun IntArray.countingSort(place: Int): IntArray {
18 | val result = IntArray(size)
19 | val count = IntArray(10)
20 |
21 | for (i in result.indices) {
22 | val digit = (this[i] / place) % 10
23 | count[digit] += 1
24 | }
25 |
26 | for (i in 1 until count.size) {
27 | count[i] += count[i - 1]
28 | }
29 |
30 | for (i in size - 1 downTo 0) {
31 | val digit = (this[i] / place) % 10
32 | result[count[digit] - 1] = this[i]
33 | count[digit]--
34 | }
35 |
36 | return result
37 | }
38 |
39 | private fun IntArray.getMax(): Int {
40 | var mx = this[0]
41 | for (i in 1 until size)
42 | if (this[i] > mx)
43 | mx = this[i]
44 | return mx
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/selection_sort/SelectionSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.selection_sort
2 |
3 | /**
4 | * Selection sort
5 | *
6 | * @constructor Create empty Selection sort
7 | */
8 |
9 | class SelectionSort {
10 | suspend fun selectionSort(
11 | arr: IntArray,
12 | ) {
13 | for (i in 1 until arr.size) {
14 | var min = i
15 | for (j in (i + 1) until arr.size) {
16 | if (arr[j] < arr[min])
17 | min = j
18 | }
19 |
20 | sortSwap(arr, min, i)
21 | }
22 | }
23 |
24 | private fun sortSwap(arr: IntArray, min: Int, i: Int) {
25 |
26 | val temp = arr[min]
27 | arr[min] = arr[i]
28 | arr[i] = temp
29 | }
30 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/sorting/shell_sort/ShellSort.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.sorting.shell_sort
2 |
3 | /**
4 | * Shell Sort
5 | *
6 | * A class carrying functionality to perform shell sort
7 | *
8 | * @constructor Creates an instance of the ShellSort class
9 | *
10 | * 1. Main idea of shell sort is comparing distant elements
11 | * 2. Efficiency of shell sort depends upon the gap {Better the gap sequence less time taken to sort the array}
12 | *
13 | * Time Complexity : O(n^2)
14 | * Space Complexity : O(1)
15 | * */
16 |
17 | class ShellSort {
18 | suspend fun shellSort(
19 | arr: IntArray
20 | ) {
21 | val n = arr.size
22 |
23 | /* Distance between two distant element is called interval / gap */
24 | var interval = n / 2
25 | while (interval > 0) {
26 | /* First Sort the gap element from range [0..gap - 1] */
27 | var i = interval
28 | while (i < n) {
29 |
30 | val temp = arr[i]
31 | var j = i
32 | /* Shift earlier gap-sorted elements up until the correct location for a[i] is found */
33 | while (j >= interval && arr[j - interval] > temp) {
34 | arr[j] = arr[j - interval]
35 | j -= interval
36 | }
37 | /* insert temp(arr[i]) in it's correct position */
38 | arr[j] = temp
39 | i += 1
40 | }
41 | /* Reduce the gap with each iteration */
42 | interval /= 2
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/stack/Stack.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.stack
2 |
3 | import java.util.ArrayList
4 |
5 | class Stack(var sz: Int) {
6 | private var arrayList: ArrayList = ArrayList()
7 | fun push(item: E): E? {
8 | if (isFull) {
9 | println("STACK IS FULL")
10 | return null
11 | }
12 | arrayList.add(item)
13 | return item
14 | }
15 |
16 | fun pop(): E? {
17 | if (isEmpty) {
18 | return null
19 | }
20 | val len = size()
21 | val obj: E? = peek()
22 | arrayList.removeAt(len - 1)
23 | return obj
24 | }
25 |
26 | fun peek(): E? {
27 | val len = size()
28 | if (isEmpty) {
29 | return null
30 | }
31 | return arrayList[len - 1]
32 | }
33 |
34 | val isFull: Boolean
35 | get() = sz == arrayList.size
36 | val isEmpty: Boolean
37 | get() = arrayList.size == 0
38 |
39 | private fun size(): Int {
40 | return arrayList.size
41 | }
42 | }
43 |
44 | fun main() {
45 | val st = Stack(5);
46 | st.isEmpty
47 | st.isFull
48 | println(st.peek())
49 | println(st.pop())
50 | println(st.pop())
51 | println(st.pop())
52 | println(st.pop())
53 | println(st.pop())
54 | println(st.pop())
55 | println(st.pop())
56 | println(st.pop())
57 | println(st.pop())
58 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/tree/avl_tree/AVLTree.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.tree.avl_tree
2 |
3 | class AVLTree{
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/tree/binary_tree/BinaryTree.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.tree.binary_tree
2 |
3 | class Node(var key: Int) {
4 | var left: Node?
5 | var right: Node? = null
6 |
7 | init {
8 | left = right
9 | }
10 | }
11 |
12 | class BinaryTree {
13 | // Root of Binary Tree
14 | var root: Node? = null
15 |
16 | /* Given a binary tree, print its nodes according to the
17 | "bottom-up" postorder traversal. */
18 | // Wrappers over above recursive functions
19 | @JvmOverloads
20 | fun printPostorder(node: Node? = root) {
21 | if (node == null) return
22 |
23 | // first recur on left subtree
24 | printPostorder(node.left)
25 |
26 | // then recur on right subtree
27 | printPostorder(node.right)
28 |
29 | // now deal with the node
30 | print(node.key.toString() + " ")
31 | }
32 |
33 | /* Given a binary tree, print its nodes in inorder*/
34 | @JvmOverloads
35 | fun printInorder(node: Node? = root) {
36 | if (node == null) return
37 |
38 | /* first recur on left child */printInorder(node.left)
39 |
40 | /* then print the data of node */print(node.key.toString() + " ")
41 |
42 | /* now recur on right child */printInorder(node.right)
43 | }
44 |
45 | /* Given a binary tree, print its nodes in preorder*/
46 | @JvmOverloads
47 | fun printPreorder(node: Node? = root) {
48 | if (node == null) return
49 |
50 | /* first print data of node */print(node.key.toString() + " ")
51 |
52 | /* then recur on left subtree */printPreorder(node.left)
53 |
54 | /* now recur on right subtree */printPreorder(node.right)
55 | }
56 |
57 | companion object {
58 | // Driver method
59 | @JvmStatic
60 | fun main(args: Array) {
61 | val tree = BinaryTree()
62 | tree.root = Node(1)
63 | tree.root!!.left = Node(2)
64 | tree.root!!.right = Node(3)
65 | tree.root!!.left!!.left = Node(4)
66 | tree.root!!.left!!.right = Node(5)
67 | println(
68 | "Preorder traversal of binary tree is "
69 | )
70 | tree.printPreorder()
71 | println(
72 | "\nInorder traversal of binary tree is "
73 | )
74 | tree.printInorder()
75 | println(
76 | "\nPostorder traversal of binary tree is "
77 | )
78 | tree.printPostorder()
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/tree/heap/Heap.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.tree.heap
2 |
3 | import java.util.*
4 |
5 | object MinHeap {
6 | @JvmStatic
7 | fun main(args: Array) {
8 | val sc = Scanner(System.`in`)
9 | print("Enter the Heap Capacity: ")
10 | val hCap: Int = sc.nextInt()
11 | val hp = Min_Heap(hCap)
12 | var flag = true
13 | var `val` = 0
14 | while (flag) {
15 | println()
16 | println("0. Exit")
17 | println("1 - Insert an Element")
18 | println("2 - Display the Heap")
19 | println("3 - Height of the Heap")
20 | println("4 - Current Heap Size")
21 | println("5 - minExtract()")
22 | println("6 - Delete Key")
23 | println("7 - Heap Sort")
24 | print("Enter Your Choice: ")
25 | val ch: Int = sc.nextInt()
26 | when (ch) {
27 | 0 -> flag = false
28 | 1 -> {
29 | print("Enter Value to be Inserted: ")
30 | `val` = sc.nextInt()
31 | hp.insert(`val`)
32 | }
33 | 2 -> hp.display()
34 | 3 -> println(
35 | "Height of Heap Tree = " + (Math.ceil(
36 | Math.log((hp.hSize + 1).toDouble()) / Math.log(
37 | 2.0
38 | )
39 | ).toInt() - 1)
40 | )
41 | 4 -> println("The Size of the Heap is = " + hp.hSize)
42 | 5 -> println(hp.minExtract())
43 | 6 -> {
44 | print("Enter Key to be Deleted: ")
45 | `val` = sc.nextInt()
46 | hp.minDeleteKey(`val`)
47 | }
48 | 7 -> {
49 | hp.hSize = hp.hCap
50 | println("Enter Elements of Unsorted Array:")
51 | var i = 0
52 | while (i < hp.hCap) {
53 | hp.hArr[i] = sc.nextInt()
54 | i++
55 | }
56 | hp.heapSort(hp.hArr)
57 | }
58 | else -> println("Invalid Choice")
59 | }
60 | }
61 | }
62 | }
63 |
64 | internal class Min_Heap(var hCap: Int) {
65 | var hArr: IntArray
66 | var hSize = 0
67 |
68 | init {
69 | hArr = IntArray(hCap)
70 | }
71 |
72 | fun parent(i: Int): Int {
73 | return (i - 1) / 2
74 | }
75 |
76 | fun left(i: Int): Int {
77 | return 2 * i + 1
78 | }
79 |
80 | fun right(i: Int): Int {
81 | return 2 * i + 2
82 | }
83 |
84 | fun swap(currI: Int, swI: Int) { // currentIndex, swapIndex
85 | val temp = hArr[currI]
86 | hArr[currI] = hArr[swI]
87 | hArr[swI] = temp
88 | }
89 |
90 | // START 1 - Insert an Element
91 | fun insert(`val`: Int) {
92 | if (hSize == hCap) {
93 | println("Heap Overflow")
94 | return
95 | }
96 | println("Value Inserted in Heap")
97 | hSize++
98 | var i = hSize - 1
99 | hArr[i] = `val`
100 |
101 | // if the new inserted node is less than its parent then swap them
102 | while (i != 0 && hArr[i] < hArr[parent(i)]) {
103 | swap(i, parent(i))
104 | i = parent(i)
105 | }
106 | }
107 |
108 | // END 1 - Insert an Element
109 | // START 2 - Display the Heap
110 | fun display() {
111 | for (i in 0 until hSize) print(hArr[i].toString() + " ")
112 | }
113 |
114 | // END 2 - Display the Heap
115 | // START 5 - minExtract()
116 | fun minExtract(): Int {
117 | if (hSize <= 0) {
118 | println("Empty heap")
119 | return -99999
120 | }
121 | if (hSize == 1) {
122 | hSize--
123 | return hArr[0]
124 | }
125 | val root = hArr[0]
126 | hArr[0] = hArr[hSize - 1]
127 | hSize--
128 | minHeapify(0)
129 | return root
130 | }
131 |
132 | fun minHeapify(i: Int) {
133 | val l = left(i)
134 | val r = right(i)
135 | var smallest = i
136 | if (l < hSize && hArr[l] < hArr[smallest]) smallest = l
137 | if (r < hSize && hArr[r] < hArr[smallest]) smallest = r
138 | if (smallest != i) {
139 | swap(i, smallest)
140 | minHeapify(smallest)
141 | }
142 | }
143 |
144 | // END 5 - minExtract()
145 | // START 6 - Delete Key
146 | fun minDeleteKey(i: Int) {
147 | if (i >= hSize) {
148 | println("Enter valid key")
149 | return
150 | }
151 | decreaseKey(i, Int.MIN_VALUE)
152 | minExtract()
153 | println("Value Deleted")
154 | }
155 |
156 | // this () will set the value in deletingIndex with minimum value than will keep
157 | // on swapping that deletingIndex value with its parents until it reaches root
158 | // then minExtract() will be called to remove the root(which is
159 | // Integer.MIN_VALUE) and heapify
160 | fun decreaseKey(i: Int, minVal: Int) {
161 | var i = i
162 | hArr[i] = minVal
163 | while (i != 0 && hArr[i] < hArr[parent(i)]) {
164 | swap(i, parent(i))
165 | i = parent(i)
166 | }
167 | }
168 |
169 | // END 6 - Delete Key
170 | // START 7 - Heap Sort
171 | fun heapSort(unsortedArr: IntArray) {
172 | System.out.println(
173 | """
174 |
175 | Unsorted Array = ${Arrays.toString(unsortedArr)}
176 | """.trimIndent()
177 | )
178 |
179 | // this will convert array into a min-heap array from bottom to top
180 | for (i in unsortedArr.size / 2 - 1 downTo 0) {
181 | minHeapify(i)
182 | }
183 |
184 | // actual heap sort starts
185 | val sortedArr = IntArray(unsortedArr.size)
186 | for (i in sortedArr.indices) {
187 | sortedArr[i] = minExtract()
188 | }
189 | System.out.println("Sorted Array = " + Arrays.toString(sortedArr))
190 | } // END 7 - Heap Sort
191 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/dsa/tree/tries/Tries.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.dsa.tree.tries
2 |
3 | object Trie_Array {
4 | @JvmStatic
5 | fun main(args: Array) {
6 | val tr = Trie_Ar()
7 | tr.insert("antman")
8 | tr.insert("ant")
9 | tr.insert("batman")
10 | tr.insert("bat")
11 | tr.insert("batball")
12 | tr.insert("pranay")
13 | tr.insert("anu")
14 | tr.insert("test")
15 | tr.insert("testing")
16 | println(tr.search("hello"))
17 | println(tr.search("ant"))
18 | println(tr.search("bat"))
19 | println(tr.search("antman"))
20 | println(tr.search("pranay"))
21 | println(tr.startsWith("an"))
22 | println(tr.startsWith("prana"))
23 | println(tr.startsWith("bat"))
24 | // checking delete function
25 | println(tr.search("ant"))
26 | tr.delete("ant")
27 | println(tr.search("ant"))
28 | }
29 | }
30 |
31 | internal class Trie_Ar {
32 | internal inner class Node(var data: Char) {
33 | var next: Array
34 | var count // this will keep the count for the no. of words formed using particular character
35 | : Int
36 | var isEnd: Boolean
37 |
38 | init {
39 | next = arrayOfNulls(26)
40 | isEnd = false
41 | count = 0
42 | }
43 | }
44 |
45 | var root: Node
46 |
47 | init {
48 | root = Node('\u0000')
49 | }
50 |
51 | fun insert(word: String) {
52 | var curr: Node? = root
53 | for (c in word.toCharArray()) {
54 | if (curr!!.next[c - 'a'] == null) curr.next[c - 'a'] = Node(c)
55 | curr.next[c - 'a']!!.count++
56 | curr = curr.next[c - 'a']
57 | }
58 | curr!!.isEnd = true //this marks the end of the word, so now the word exists in the trie
59 | }
60 |
61 | fun search(word: String): Boolean {
62 | var curr: Node? = root
63 | for (c in word.toCharArray()) {
64 | if (curr!!.next[c - 'a'] == null) return false
65 | curr = curr.next[c - 'a']
66 | }
67 | return curr!!.isEnd
68 | }
69 |
70 | // return true if any word with "prefix" is present in trie
71 | fun startsWith(prefix: String): Boolean {
72 | var curr: Node? = root
73 | for (c in prefix.toCharArray()) {
74 | if (curr!!.next[c - 'a'] == null) return false
75 | curr = curr.next[c - 'a']
76 | }
77 | println("No. of string formed using prefix - '" + prefix + "' is = " + curr!!.count)
78 | return true
79 | }
80 |
81 | fun delete(word: String) {
82 | if (search(word)) {
83 | var curr: Node? = root
84 | for (c in word.toCharArray()) {
85 | curr = curr!!.next[c - 'a']
86 | }
87 | curr!!.isEnd =
88 | false //this unmarks the end of word, so now the entire word is non-existent in the trie
89 | println("Deleted")
90 | } else {
91 | println("Word not fount")
92 | return
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/feature_onboarding/OnboardingActivity.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.feature_onboarding
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.compose.foundation.background
7 | import androidx.compose.foundation.layout.*
8 | import androidx.compose.material.MaterialTheme
9 | import androidx.compose.ui.Alignment
10 | import androidx.compose.ui.Modifier
11 | import androidx.compose.ui.graphics.Color
12 | import androidx.compose.ui.unit.dp
13 | import androidx.lifecycle.ViewModelProvider
14 | import com.dlight.algoguide.composables.onboarding_screen.OnboardingPager
15 | import com.dlight.algoguide.dsa.sorting.Events
16 | import com.dlight.algoguide.dsa.sorting.SortViewModel
17 | import com.dlight.algoguide.dsa.sorting.SortingViewModelProvider
18 | import com.dlight.algoguide.dsa.sorting.composables.VisualizerBottomBar
19 | import com.dlight.algoguide.dsa.sorting.composables.VisualizerSection
20 | import com.dlight.algoguide.dsa.sorting.insertion_sort.InsertionSort
21 | import com.dlight.algoguide.feature_onboarding.data.OnboardingData
22 | import com.dlight.algoguide.ui.theme.AlgoGuideTheme
23 | import com.google.accompanist.pager.ExperimentalPagerApi
24 | import com.google.accompanist.pager.rememberPagerState
25 |
26 | /**
27 | * Main activity
28 | *
29 | * @constructor Create empty Main activity
30 | */
31 | class OnboardingActivity : ComponentActivity() {
32 |
33 |
34 | private val viewModel: SortViewModel by lazy {
35 | val viewModelProviderFactory = SortingViewModelProvider(InsertionSort())
36 | ViewModelProvider(this, viewModelProviderFactory)[
37 | SortViewModel::class.java]
38 | }
39 |
40 | @ExperimentalPagerApi
41 | override fun onCreate(savedInstanceState: Bundle?) {
42 | super.onCreate(savedInstanceState)
43 | setContent {
44 | AlgoGuideTheme {
45 |
46 | //onBoarding screen
47 | val items = ArrayList()
48 | items.add(
49 | OnboardingData(
50 |
51 | "Easy Algo Guides",
52 | "We have number of algorithm concepts"
53 | )
54 | )
55 | items.add(
56 | OnboardingData(
57 | "Easy Algo Guides",
58 | "We have number of algorithm concepts"
59 | )
60 | )
61 | items.add(
62 | OnboardingData(
63 | "Easy Algo Guides",
64 | "We have number of algorithm concepts"
65 | )
66 | )
67 |
68 | val pagerState = rememberPagerState(
69 | pageCount = items.size,
70 | initialOffscreenLimit = 2,
71 | infiniteLoop = false,
72 | initialPage = 0,
73 | )
74 |
75 | OnboardingPager(
76 | item = items,
77 | pagerState = pagerState,
78 | modifier = Modifier
79 | .fillMaxWidth()
80 | .background(color = Color.Black)
81 | )
82 |
83 |
84 | // A surface container using the 'background' color from the theme
85 | // Box(
86 | // modifier = Modifier
87 | // .fillMaxSize()
88 | // .background(MaterialTheme.colors.background),
89 | // contentAlignment = Alignment.BottomCenter
90 | // ) {
91 | // Column {
92 | // VisualizerSection(
93 | // arr = viewModel.arr.value,
94 | // modifier = Modifier
95 | // )
96 | //
97 | // val isPlaying = viewModel.sortingStart.value
98 | // val isFinished = viewModel.sortFinish.value
99 | //
100 | // VisualizerBottomBar(
101 | // playPauseClick = { viewModel.onEvent(Events.playPause) },
102 | // slowDownClick = { viewModel.onEvent(Events.slowDown) },
103 | // speedUpClick = { viewModel.onEvent(Events.speedUp) },
104 | // previousClick = { viewModel.onEvent(Events.previous) },
105 | // nextClick = { viewModel.onEvent(Events.next) },
106 | // modifier = Modifier
107 | // .fillMaxWidth()
108 | // .height(75.dp),
109 | // isPlaying = if (isFinished) !isFinished else isPlaying
110 | // )
111 | // }
112 | // }
113 | }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/feature_onboarding/data/OnboardingData.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.feature_onboarding.data
2 |
3 | data class OnboardingData(val title: String, val description: String) {
4 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/feature_onboarding/model/OnboardingGoalSetting.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.feature_onboarding.model
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.background
5 | import androidx.compose.foundation.layout.Box
6 | import androidx.compose.foundation.layout.height
7 | import androidx.compose.foundation.layout.padding
8 | import androidx.compose.foundation.layout.width
9 | import androidx.compose.material.Text
10 | import androidx.compose.runtime.Composable
11 | import androidx.compose.ui.Alignment
12 | import androidx.compose.ui.Modifier
13 | import androidx.compose.ui.focus.FocusRequester.Companion.FocusRequesterFactory.component12
14 | import androidx.compose.ui.graphics.Color
15 | import androidx.compose.ui.res.painterResource
16 | import androidx.compose.ui.text.TextStyle
17 | import androidx.compose.ui.text.font.FontWeight
18 | import androidx.compose.ui.unit.dp
19 | import androidx.compose.ui.unit.sp
20 | import com.dlight.algoguide.R
21 |
22 | @Composable
23 | fun OnboardingGoalSetting() {
24 | Box(
25 | contentAlignment = Alignment.TopCenter,
26 | modifier = Modifier
27 | .width(width = 375.dp)
28 | .height(height = 812.dp)
29 | .padding(start = 35.dp,
30 | end = 36.dp,
31 | top = 70.dp,
32 | bottom = 34.dp)
33 | .background(color = Color.White)
34 | ) {
35 | Text(
36 | text = " Daily remainder",
37 | color = Color.Black,
38 | style = TextStyle(
39 | fontSize = 20.sp,
40 | fontWeight = FontWeight.Bold)
41 | )
42 | Text(
43 | text = "Set a daily Goal",
44 | color = Color.Black,
45 | style = TextStyle(
46 | fontSize = 40.sp,
47 | fontWeight = FontWeight.Bold))
48 | Component()
49 | Component()
50 | Box(
51 | modifier = Modifier
52 | .width(width = 279.dp)
53 | .height(height = 67.dp)
54 | .background(color = Color(0xff17a1fa)))
55 | Text(
56 | text = "Get Started >>",
57 | color = Color.Black,
58 | style = TextStyle(
59 | fontSize = 25.sp,
60 | fontWeight = FontWeight.Bold))
61 | Component()
62 | Component()
63 | Image(
64 | painter = painterResource(id = R.drawable.ic_play),
65 | contentDescription = "Component 12",
66 | modifier = Modifier
67 | .width(width = 70.dp)
68 | .height(height = 30.dp))
69 | }
70 | }
71 |
72 | @Composable
73 | fun Component() {
74 | Box(
75 | contentAlignment = Alignment.Center,
76 | modifier = Modifier
77 | .width(width = 136.dp)
78 | .height(height = 200.dp)
79 | ) {
80 | Box(
81 | modifier = Modifier
82 | .width(width = 136.dp)
83 | .height(height = 200.dp)
84 | .background(color = Color(0xffd9d9d9)))
85 | Text(
86 | text = "min /day",
87 | color = Color.Black,
88 | style = TextStyle(
89 | fontSize = 25.sp))
90 | Text(
91 | text = "20",
92 | color = Color.Black,
93 | style = TextStyle(
94 | fontSize = 40.sp,
95 | fontWeight = FontWeight.Bold))
96 | }
97 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/feature_onboarding/use_cases/OnboardingPager.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.composables.onboarding_screen
2 |
3 | import androidx.annotation.FloatRange
4 | import androidx.compose.animation.core.animateDpAsState
5 | import androidx.compose.foundation.Image
6 | import androidx.compose.foundation.background
7 | import androidx.compose.foundation.layout.*
8 | import androidx.compose.foundation.shape.CircleShape
9 | import androidx.compose.foundation.shape.RoundedCornerShape
10 | import androidx.compose.material.MaterialTheme
11 | import androidx.compose.material.MaterialTheme.colors
12 | import androidx.compose.material.OutlinedButton
13 | import androidx.compose.material.Text
14 | import androidx.compose.runtime.Composable
15 | import androidx.compose.runtime.saveable.rememberSaveable
16 | import androidx.compose.ui.Alignment
17 | import androidx.compose.ui.Modifier
18 | import androidx.compose.ui.draw.clip
19 | import androidx.compose.ui.graphics.Color
20 | import androidx.compose.ui.res.painterResource
21 | import androidx.compose.ui.text.font.FontWeight
22 | import androidx.compose.ui.text.style.TextAlign
23 | import androidx.compose.ui.unit.dp
24 | import androidx.compose.ui.unit.sp
25 | import com.dlight.algoguide.feature_onboarding.data.OnboardingData
26 | import com.google.accompanist.pager.ExperimentalPagerApi
27 | import com.google.accompanist.pager.HorizontalPager
28 | import com.google.accompanist.pager.PagerState
29 |
30 |
31 | @ExperimentalPagerApi
32 | @Composable
33 | fun OnboardingPager(
34 | item: List,
35 | pagerState: PagerState,
36 | modifier: Modifier = Modifier
37 | ) {
38 | Box(modifier = modifier) {
39 | Column(horizontalAlignment = Alignment.CenterHorizontally) {
40 | HorizontalPager(state = pagerState) { page ->
41 | Column(
42 | modifier = Modifier
43 | .padding(top = 60.dp)
44 | .fillMaxWidth(),
45 | horizontalAlignment = Alignment.CenterHorizontally
46 | ) {
47 | // Image(
48 | // // painter = painterResource(id = item[page].image),
49 | // contentDescription = item[page].title,
50 | // modifier = Modifier
51 | // .height(250.dp)
52 | // .fillMaxWidth()
53 | // )
54 | Text(
55 | text = item[page].title,
56 | modifier = Modifier.padding(top = 50.dp),
57 | color = Color.White
58 | )
59 | Text(
60 | text = item[page].description,
61 | modifier = Modifier.padding(top = 50.dp),
62 | color = Color.White,
63 | fontSize = 18.sp,
64 | textAlign = TextAlign.Center
65 | )
66 | }
67 | }
68 | PagerIndicator(item.size, pagerState.currentPage)
69 | }
70 | Box(modifier = Modifier.align(Alignment.BottomCenter)) {
71 | BottomSection(pagerState.currentPage)
72 | }
73 | }
74 | }
75 | @ExperimentalPagerApi
76 | @Composable
77 | fun RememberPagerState(
78 | @androidx.annotation.IntRange(from = 0) pageCount: Int,
79 | @androidx.annotation.IntRange(from = 0) initialPage: Int = 0,
80 | @FloatRange(from = 0.0, to = 1.0) initialPagerOffset: Float = 0f,
81 | @androidx.annotation.IntRange(from = 1) initialOffscreenLimit: Int = 1,
82 | infiniteLoop: Boolean = false
83 | ): PagerState = rememberSaveable(saver = PagerState.Saver) {
84 | PagerState(
85 | pageCount = pageCount,
86 | currentPage = initialPage,
87 | currentPageOffset = initialPagerOffset,
88 | offscreenLimit = initialOffscreenLimit,
89 | infiniteLoop = infiniteLoop
90 | )
91 | }
92 |
93 | @Composable
94 | fun Indicator(isSelected: Boolean) {
95 | val width = animateDpAsState(targetValue = if (isSelected) 25.dp else 10.dp)
96 | Box(
97 | modifier = Modifier
98 | .padding(1.dp)
99 | .height(10.dp)
100 | .width(width.value)
101 | .clip(CircleShape)
102 | .background(
103 | if (isSelected) MaterialTheme.colors.primary else colors.background.copy(alpha = 0.5f)
104 | )
105 | )
106 | }
107 |
108 | @Composable
109 | fun SkipNextButton(
110 | text: String,
111 | modifier: Modifier
112 | ) {
113 | Text(
114 | text = text,
115 | color = Color.Black,
116 | modifier = modifier,
117 | fontSize = 18.sp,
118 | fontWeight = FontWeight.Medium
119 | )
120 | }
121 |
122 | @Composable
123 | fun BottomSection(currentPager: Int) {
124 | Row(
125 | modifier = Modifier
126 | .padding(bottom = 20.dp)
127 | .fillMaxWidth(),
128 | horizontalArrangement = if (currentPager != 2) Arrangement.SpaceBetween else Arrangement.Center
129 | ) {
130 | if (currentPager == 2) {
131 | OutlinedButton(
132 | onClick = { /*TODO*/ },
133 | shape = RoundedCornerShape(50)
134 | ) {
135 | Text(
136 | text = "Get Started",
137 | modifier = Modifier.padding(vertical = 8.dp, horizontal = 40.dp),
138 | color = Color.Black
139 | )
140 | }
141 | } else {
142 | SkipNextButton(
143 | "Skip", Modifier
144 | .padding(start = 20.dp)
145 | )
146 | SkipNextButton(
147 | "Next", Modifier
148 | .padding(end = 20.dp)
149 | )
150 | }
151 | }
152 | }
153 |
154 | @Composable
155 | fun PagerIndicator(size: Int, currentPage: Int) {
156 | Row(
157 | horizontalArrangement = Arrangement.SpaceBetween,
158 | modifier = Modifier.padding(top = 60.dp)
159 | ) {
160 | repeat(size) {
161 | Indicator(isSelected = it == currentPage)
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/ui/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.ui.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/ui/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.ui.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/ui/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.ui.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun AlgoGuideTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/dlight/algoguide/ui/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide.ui.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | )
16 | /* Other default text styles to override
17 | button = TextStyle(
18 | fontFamily = FontFamily.Default,
19 | fontWeight = FontWeight.W500,
20 | fontSize = 14.sp
21 | ),
22 | caption = TextStyle(
23 | fontFamily = FontFamily.Default,
24 | fontWeight = FontWeight.Normal,
25 | fontSize = 12.sp
26 | )
27 | */
28 | )
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/algorithm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/drawable/algorithm.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_pause.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_play.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_slow.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Algo Guide
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/app/src/test/java/com/dlight/algoguide/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.dlight.algoguide
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext {
3 | compose_version = '1.1.0-beta01'
4 | }
5 | }// Top-level build file where you can add configuration options common to all sub-projects/modules.
6 | plugins {
7 | id 'com.android.application' version '7.4.2' apply false
8 | id 'com.android.library' version '7.4.2' apply false
9 | id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
10 | id 'org.jetbrains.dokka' version '1.7.0' apply false
11 | }
12 |
13 | task clean(type: Delete) {
14 | delete rootProject.buildDir
15 | }
16 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kodeflap/Algo_Guide/c4a7ddba54daecb219a1befa12583e3e8f3fa066/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jul 02 21:38:24 IST 2022
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Describe your changes
2 |
3 | Fixes # (issue)
4 |
5 | ## Checklist before requesting a review
6 | - [ ] I have performed a self-review of my code
7 | - [ ] If it is a core feature, I have added thorough tests.
8 | - [ ] Do we need to implement analytics?
9 | - [ ] Will this be part of a product update? If yes, please write one phrase about this update.
10 |
11 | ## Type of change
12 |
13 | Please delete options that are not relevant.
14 |
15 | - [ ] Bug fix (non-breaking change which fixes an issue)
16 | - [ ] New feature (non-breaking change which adds functionality)
17 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
18 | - [ ] This change requires a documentation update
19 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | gradlePluginPortal()
4 | google()
5 | mavenCentral()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "Algo Guide"
16 | include ':app'
17 |
--------------------------------------------------------------------------------