From 55eda4be19daf338d642422e6533dbbab83b313c Mon Sep 17 00:00:00 2001 From: Anshul Gautam Date: Thu, 25 Oct 2018 16:38:14 +0530 Subject: [PATCH 1/7] most effeicient O(n) --- Algorithms/sorting/Python/MergeSort1.py | Bin 0 -> 900 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Algorithms/sorting/Python/MergeSort1.py diff --git a/Algorithms/sorting/Python/MergeSort1.py b/Algorithms/sorting/Python/MergeSort1.py new file mode 100644 index 0000000000000000000000000000000000000000..c0bfb5dbe384d681f7860ae3c6938c5501b17727 GIT binary patch literal 900 zcmZ9LOD_Xa6vywVXJSz_-ibzRYo?lZ5DC>sEC`85Y^OSCim91yh(+xzEG#V~d;y8X zMp&4orH?^ESdd7F`k!&G;v}c{_doaEbMHBGo3X6CfUO(0Hx7cyCw&yH_S3KJs7A-B zb^hqOaneTCQMD?}f_=0OP=i5HgqU|s+X2_IHdZp30s?iclctj|S_M(hIx(G0B_>ko zM%GiNy<*N-}K*_GE3(-*1<= J7yQEOzW^(LTh;&o literal 0 HcmV?d00001 From 0a54b87f9c840a0821e47221a02b6e74e5eb16b4 Mon Sep 17 00:00:00 2001 From: Anshul Gautam Date: Thu, 25 Oct 2018 16:51:00 +0530 Subject: [PATCH 2/7] Count Sort O(nK) --- Algorithms/sorting/Python/CountSort.py | Bin 0 -> 900 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Algorithms/sorting/Python/CountSort.py diff --git a/Algorithms/sorting/Python/CountSort.py b/Algorithms/sorting/Python/CountSort.py new file mode 100644 index 0000000000000000000000000000000000000000..4e9571a8c5dc600a48fbc8ef392cffa6e0a20483 GIT binary patch literal 900 zcmZ9LOD_Xa6vyv)ODu}UJJE=p)J!$)v_j}J7KFqjwo@%_(5X%>hy^d7Z_!eXi~RG@ zlWj-HH`11>)nFD}OX~pj7!*Z_MJrRZzzyshYpGNLfkyV@8Ed^{7DN;KvDtVcHkC-W zNZ;Jfm*&l4X}GZCrWg{@B|MM@O+s@J?XSbxmpMAA>YrUT|MAQJ{M{a^uDX8wbj$JO zS^Mygp>wDV*$|yYHAZav@dnrhDX1UiI@S*+lOwT$hRFWV4JA{%e% zVKujr8C6wP_GQLc$>mF?mGw-;<$i2^>*ajT{jR&;58)3&^eyyYIGoU932)RF@O%Bq zK)@T(f>Ce4=a2YxUDK1nkgVl^_CQbVe@BW@E*0YlF=|ccb1C3Y{lwC^6{4^+0h3W7 z+{p1+sZ=N*SqDU~EA4oAKj1rN7x;sD68ylt03PH7i(rj;3EanA;}PPXxgNaC>;h+* zTfryHZQwoTcJL9i2Ykz{fn|Qh7GjL!tzb+!)@I{B!*S)Vy50q*Z%@|w{QY)`2f#19 F{tN4BTPgqm literal 0 HcmV?d00001 From 4b0978c82f90ca6d7de72c5e73198106efefc336 Mon Sep 17 00:00:00 2001 From: Anshul Gautam Date: Thu, 25 Oct 2018 17:07:07 +0530 Subject: [PATCH 3/7] new file --- Algorithms/sorting/Python/RadixSort.py | Bin 0 -> 900 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Algorithms/sorting/Python/RadixSort.py diff --git a/Algorithms/sorting/Python/RadixSort.py b/Algorithms/sorting/Python/RadixSort.py new file mode 100644 index 0000000000000000000000000000000000000000..7283080d25b9417bd50e1822de8e0aa5bdbf2168 GIT binary patch literal 900 zcmZ9LOD_Xa6vyvqy%LL-##=Pl)(lNMh=l4R7KC`kcB-Y5(y2}thy^`d(WAfv}NT5Y{w|M;~1EH&O=eJkDeu4HLeEz zeJ_p^BW+}CRjb1+*hA|8^%xXIh*djVvcV0kjjeRLh(IIjMApuit)ggR9bZT!|)o| z@~k7MGx#OE0(ana7S$MYoae10Avz%y)Q@sq>j#s`kyt@PWPj*}lBr$t?!;tr?hOgu zzMzCnb2~ess;cbEys=>x%9foA&L-r3Y<=&+*Rmw-!4yUgx<0^bV;Cp5t_>*}W{K&il9^wS6V2ybV+{;`S6ykxo9=y)% z1Lv6i;B)3y@F8;>_>?&azGK$FGQZ*oG0Aa17*npbI{0TeuH4tw`@r;m$vU2YzFp!0 I@GGzX2A^+QOaK4? literal 0 HcmV?d00001 From 296cf759afbf13d6365bcff54ddd7e03ebf9e97c Mon Sep 17 00:00:00 2001 From: Anshul Gautam Date: Thu, 25 Oct 2018 17:11:41 +0530 Subject: [PATCH 4/7] new sort --- Algorithms/sorting/Python/CombSort.py | Bin 0 -> 900 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Algorithms/sorting/Python/CombSort.py diff --git a/Algorithms/sorting/Python/CombSort.py b/Algorithms/sorting/Python/CombSort.py new file mode 100644 index 0000000000000000000000000000000000000000..f9ddc43410372e3392ef6b76e9e11ada1a1578b4 GIT binary patch literal 900 zcmZ9LJ4*vW5Xbj?ix%;LZ!m~$ywi}JieTPY_yQl;-kGQ&#*4W$iiLI}7JdLhZLBTD z#w#pR=3`h0Dkunw@jvIRQ3w9n-^}jL?#yjW%gP8?*2uf#D3~-|P0<<;{pM}eI4aIw zK08jBd?RVAS`}u&)wB*!i$PI@Sh7=j8(hb}v2L0<1nSw3rR+?>%83T{qjRx%bSj=` zlD?HS7p#0?D7PcpDTYLJ2`{8UA!r_={WUoII!z~4{Ii?JKmOG}f47IKtE|7f*miw+ z);_!w=p4F&9Ei@M8pDqBya()p6x5G$UF!#v$&pw=Lu7yGhLWjW^6qYnf6cujq1zXf zu$JCTjjO8KOt}!BF;>%C1PQ~PYOuhATKKFjN-S3C+2YHVk92<-4(YP-%9Ps=6 zi9o;?)`AgVVAvn_>$;{Vf}^sQ1KI;Uw*4I`M(3*-M~G2taw}~Df9fZe#;p*!ok^IC z3ek=npXG9y@{x5w^tzI+hxY?6F?+xt%pvdt^CEbV6D)x>=4EgnbCp+!d*)j33bO~i z!Q28qWo`xUF}Hz_nZ4j5vj&#=6-S5(j<NbZ6 Date: Thu, 25 Oct 2018 17:14:45 +0530 Subject: [PATCH 5/7] new type of sort --- Algorithms/sorting/Python/CycleSort.py | Bin 0 -> 900 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Algorithms/sorting/Python/CycleSort.py diff --git a/Algorithms/sorting/Python/CycleSort.py b/Algorithms/sorting/Python/CycleSort.py new file mode 100644 index 0000000000000000000000000000000000000000..dae43f1ca53d5ac214d8ea49df20fa225723c4de GIT binary patch literal 900 zcmZ9LOD_Xa6vyvq>ycR0Bi@NdY-^^Pc2o$}M=S^l72By6jmK1{n~DWH3lSfHkoW>! zij7%X`W7rC9wCts^*`fW#Yz6XzjN-r=iYPXHf@?~0=8ikoN)+DnsQOp?WNy>r5dC0 zliFw7j*@R=ELE$)EZ9Zs03HmAB1Fo{7A$Zr`^HK-okyUK{dm?|E1G#x&wgwso`_8* zl8w?YEv;wg%tCP>UuvZo6451mkOqxIvk>ifct_9~REBJb&Y~Klw*7Pq?0^*1k8&OB1(V59^en~cl-*!tGZ`JDS*b-wSz?}zAH=;25tp~n*bi9jgm z4< Date: Thu, 3 Oct 2019 00:51:50 +0530 Subject: [PATCH 6/7] Hashmap in JAVA --- Data Structures/Hash Map/hashmap.java | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Data Structures/Hash Map/hashmap.java diff --git a/Data Structures/Hash Map/hashmap.java b/Data Structures/Hash Map/hashmap.java new file mode 100644 index 0000000..2ea95b9 --- /dev/null +++ b/Data Structures/Hash Map/hashmap.java @@ -0,0 +1,44 @@ +// Java program to illustrate +// Java.util.HashMap + +import java.util.HashMap; +import java.util.Map; + +public class GFG { + public static void main(String[] args) + { + + HashMap map + = new HashMap<>(); + + print(map); + map.put("vishal", 10); + map.put("sachin", 30); + map.put("vaibhav", 20); + + System.out.println("Size of map is:- " + + map.size()); + + print(map); + if (map.containsKey("vishal")) { + Integer a = map.get("vishal"); + System.out.println("value for key" + + " \"vishal\" is:- " + + a); + } + + map.clear(); + print(map); + } + + public static void print(Map map) + { + if (map.isEmpty()) { + System.out.println("map is empty"); + } + + else { + System.out.println(map); + } + } +} From f0a05cb1d29f86f79d0d5ec9302cd7a571d3267c Mon Sep 17 00:00:00 2001 From: Anshul Gautam <40620896+anshul17024@users.noreply.github.com> Date: Thu, 3 Oct 2019 00:55:21 +0530 Subject: [PATCH 7/7] Add files via upload --- Data Structures/Hash Map/hashmap.cpp | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Data Structures/Hash Map/hashmap.cpp diff --git a/Data Structures/Hash Map/hashmap.cpp b/Data Structures/Hash Map/hashmap.cpp new file mode 100644 index 0000000..0e7ab04 --- /dev/null +++ b/Data Structures/Hash Map/hashmap.cpp @@ -0,0 +1,82 @@ +#include +#include +#include + +using namespace std; + +int main() +{ + + // empty map container + map gquiz1; + + // insert elements in random order + gquiz1.insert(pair(1, 40)); + gquiz1.insert(pair(2, 30)); + gquiz1.insert(pair(3, 60)); + gquiz1.insert(pair(4, 20)); + gquiz1.insert(pair(5, 50)); + gquiz1.insert(pair(6, 50)); + gquiz1.insert(pair(7, 10)); + + // printing map gquiz1 + map::iterator itr; + cout << "\nThe map gquiz1 is : \n"; + cout << "\tKEY\tELEMENT\n"; + for (itr = gquiz1.begin(); itr != gquiz1.end(); ++itr) { + cout << '\t' << itr->first + << '\t' << itr->second << '\n'; + } + cout << endl; + + // assigning the elements from gquiz1 to gquiz2 + map gquiz2(gquiz1.begin(), gquiz1.end()); + + // print all elements of the map gquiz2 + cout << "\nThe map gquiz2 after" + << " assign from gquiz1 is : \n"; + cout << "\tKEY\tELEMENT\n"; + for (itr = gquiz2.begin(); itr != gquiz2.end(); ++itr) { + cout << '\t' << itr->first + << '\t' << itr->second << '\n'; + } + cout << endl; + + // remove all elements up to + // element with key=3 in gquiz2 + cout << "\ngquiz2 after removal of" + " elements less than key=3 : \n"; + cout << "\tKEY\tELEMENT\n"; + gquiz2.erase(gquiz2.begin(), gquiz2.find(3)); + for (itr = gquiz2.begin(); itr != gquiz2.end(); ++itr) { + cout << '\t' << itr->first + << '\t' << itr->second << '\n'; + } + + // remove all elements with key = 4 + int num; + num = gquiz2.erase(4); + cout << "\ngquiz2.erase(4) : "; + cout << num << " removed \n"; + cout << "\tKEY\tELEMENT\n"; + for (itr = gquiz2.begin(); itr != gquiz2.end(); ++itr) { + cout << '\t' << itr->first + << '\t' << itr->second << '\n'; + } + + cout << endl; + + // lower bound and upper bound for map gquiz1 key = 5 + cout << "gquiz1.lower_bound(5) : " + << "\tKEY = "; + cout << gquiz1.lower_bound(5)->first << '\t'; + cout << "\tELEMENT = " + << gquiz1.lower_bound(5)->second << endl; + cout << "gquiz1.upper_bound(5) : " + << "\tKEY = "; + cout << gquiz1.upper_bound(5)->first << '\t'; + cout << "\tELEMENT = " + << gquiz1.upper_bound(5)->second << endl; + + return 0; +} \ No newline at end of file