Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1520 commits
Select commit Hold shift + click to select a range
3df88cd
Merge pull request #956 from Nguyen-Quoc-Thai/patch-3
heydc7 Oct 18, 2020
b31b1a1
Merge pull request #957 from Nguyen-Quoc-Thai/patch-4
heydc7 Oct 18, 2020
b15a007
Create C program for febonacci siries
MadhusudanAnand Oct 18, 2020
3ef996b
Merge pull request #958 from harshahvg7/main
heydc7 Oct 18, 2020
a72136b
Merge pull request #959 from AaronF3PS/patch-3
heydc7 Oct 18, 2020
8d43fda
Merge pull request #960 from AaronF3PS/patch-4
heydc7 Oct 18, 2020
a2a5f00
Merge pull request #961 from akshay7789/main
heydc7 Oct 18, 2020
2afa391
Merge pull request #962 from MadhusudanAnand/patch-1
heydc7 Oct 18, 2020
4511d23
Smallest.md
harshahvg7 Oct 18, 2020
bc49996
Create 2D Matrices using C
MadhusudanAnand Oct 18, 2020
995f88d
Merge pull request #963 from harshahvg7/main
heydc7 Oct 18, 2020
4c308e0
Merge pull request #964 from MadhusudanAnand/patch-2
heydc7 Oct 18, 2020
9af14cb
Create code for ASCII
MadhusudanAnand Oct 18, 2020
3cdcc56
Ceiling and floor value
Oct 18, 2020
19e5c49
Create left rotate array using c
MadhusudanAnand Oct 18, 2020
47e6b2d
Merge pull request #966 from Banjade17/patch-1
heydc7 Oct 18, 2020
4dddec6
Merge pull request #965 from MadhusudanAnand/patch-3
heydc7 Oct 18, 2020
b6bee1f
Create binary search tree
Nguyen-Quoc-Thai Oct 18, 2020
f80e503
Create valleys counting
Nguyen-Quoc-Thai Oct 18, 2020
ccdcddb
Create java inheritance
Nguyen-Quoc-Thai Oct 18, 2020
4baa184
Length.md
harshahvg7 Oct 18, 2020
c0c4ccd
Create Dining Philosopher Problem
babyshreeshma Oct 18, 2020
3b6121a
Merge pull request #967 from MadhusudanAnand/patch-5
heydc7 Oct 18, 2020
7342b2a
Create No of nodes in BST
babyshreeshma Oct 18, 2020
3b8f465
Create Deletion of BST
babyshreeshma Oct 18, 2020
404ab9d
Create Graph in Data Structure
babyshreeshma Oct 18, 2020
5b7721c
Merge pull request #968 from Nguyen-Quoc-Thai/patch-5
heydc7 Oct 18, 2020
dee20fb
Create Program to find the sum of array elements
shubhamkumarcs Oct 18, 2020
1f55938
Update C++
shadoww19 Oct 18, 2020
c8807a0
Merge pull request #969 from Nguyen-Quoc-Thai/patch-6
heydc7 Oct 18, 2020
bfd6046
Update C_Program Factorial
shadoww19 Oct 18, 2020
3429260
Merge pull request #970 from Nguyen-Quoc-Thai/patch-7
heydc7 Oct 18, 2020
3697474
Merge pull request #971 from harshahvg7/main
heydc7 Oct 18, 2020
4508f38
Merge pull request #972 from babyshreeshma/patch-1
heydc7 Oct 18, 2020
5e17181
Heap Sort C++ Program
KhushiJain2810 Oct 18, 2020
12c1cd8
Create Binary to decimal using python
shaonidutta Oct 18, 2020
659f7be
Create To-Reverse-the-array-in-java
Anjali401 Oct 18, 2020
0185b3d
Find any word form text
Oct 18, 2020
982f0d8
Create Convert Decimal to Binary, Octal and Hexadecimal using python
shaonidutta Oct 18, 2020
ed11d60
Create Program to find largest element in array using c
hack1920 Oct 18, 2020
7f5b3bb
Merge pull request #973 from babyshreeshma/patch-2
heydc7 Oct 18, 2020
2e8bcf5
Create Program to print prime numbers in given range using c
hack1920 Oct 18, 2020
0a915c6
Merge pull request #974 from babyshreeshma/patch-3
heydc7 Oct 18, 2020
f449327
Merge pull request #975 from babyshreeshma/patch-4
heydc7 Oct 18, 2020
a56f1f8
Create Program to find lenght of a string using python
hack1920 Oct 18, 2020
a37f568
Create Multiplicative Inverse using Extended Euclidean Algorithm
Oct 18, 2020
31d054a
Create Program to count sum of all numbers in array using c
hack1920 Oct 18, 2020
fc51075
Merge pull request #976 from shubhamkumarcs/main
heydc7 Oct 18, 2020
4474677
Merge pull request #977 from shadoww19/patch-2
heydc7 Oct 18, 2020
9bc150e
Merge pull request #978 from shadoww19/patch-3
heydc7 Oct 18, 2020
a7d35c8
Merge pull request #979 from KhushiJain2810/patch-2
heydc7 Oct 18, 2020
3688821
Merge pull request #980 from shaonidutta/patch-1
heydc7 Oct 18, 2020
cbf9398
Find length of a string
newcharacteryigit Oct 18, 2020
3fbcee2
Merge pull request #981 from Banjade17/patch-2
heydc7 Oct 18, 2020
205ddb4
Update ProgramToConvertBinaryToDecimalNumber.cpp
shadoww19 Oct 18, 2020
33a1658
Merge pull request #982 from Anjali401/patch-1
heydc7 Oct 18, 2020
fb0d61f
Merge pull request #983 from shaonidutta/patch-2
heydc7 Oct 18, 2020
d15a2fc
Merge pull request #984 from hack1920/patch-1
heydc7 Oct 18, 2020
cb85812
Merge pull request #985 from hack1920/patch-2
heydc7 Oct 18, 2020
297b0e0
Merge pull request #986 from hack1920/patch-3
heydc7 Oct 18, 2020
4e9b8c0
Update C String Initialization
shadoww19 Oct 18, 2020
fe733f0
Merge pull request #987 from Addhyay/patch-1
heydc7 Oct 18, 2020
40bb7d7
Merge pull request #988 from hack1920/patch-4
heydc7 Oct 18, 2020
e6f0b64
Merge pull request #989 from newcharacteryigit/patch-3
heydc7 Oct 18, 2020
d5c5573
Merge pull request #990 from shadoww19/patch-4
heydc7 Oct 18, 2020
7ca3c26
Merge pull request #991 from shadoww19/patch-7
heydc7 Oct 18, 2020
86e1e35
Create Program to print Fibonnaci Series using python
pr4n4vs Oct 18, 2020
717e143
C++ Program for Linked List
KhushiJain2810 Oct 18, 2020
3dee2ca
Create Program to find power of any number using c
pr4n4vs Oct 18, 2020
99fe5b1
Create Print leap year in a given year range
technicalreju Oct 18, 2020
b2a9195
Create Program to find largest element in array using c++
pr4n4vs Oct 18, 2020
8d70199
Merge pull request #992 from pr4n4vs/patch-1
heydc7 Oct 18, 2020
a06aa2b
Merge pull request #993 from KhushiJain2810/main
heydc7 Oct 18, 2020
e46ba84
Merge pull request #994 from pr4n4vs/patch-2
heydc7 Oct 18, 2020
ee5c976
Merge pull request #995 from technicalreju/patch-1
heydc7 Oct 18, 2020
5383d0c
Create Program to convert binary to decimal number using c
pr4n4vs Oct 18, 2020
02e2db7
Merge pull request #996 from pr4n4vs/patch-3
heydc7 Oct 18, 2020
fb281ce
Merge pull request #997 from pr4n4vs/patch-4
heydc7 Oct 18, 2020
5068b63
Create Length of a String
Shubzedm007 Oct 18, 2020
77c4a00
Create Invisibility using Python
aaryaab Oct 18, 2020
930fcab
Patterns
Pankaj6198 Oct 18, 2020
f02ab5a
Informed search algorithm (A* algorithm)
Oct 18, 2020
0fd6f9f
Create Program to reverse the array element
Shubzedm007 Oct 18, 2020
48c6d90
Binary to Decimal Program
AbhiramRajeevan Oct 18, 2020
4f33735
Create A C++ Program to print ASCII value of given character
Shubzedm007 Oct 18, 2020
af1a31a
Create String Operation using Java
aaryaab Oct 18, 2020
3909fb6
Create Python Program to convert binary to decimal number
Shubzedm007 Oct 18, 2020
e13f807
Create Menu Driven-Calculate Basic Arithmatic Operations
AbhiramRajeevan Oct 18, 2020
30848b6
Matric addition
Pankaj6198 Oct 18, 2020
5d84712
Create Calculate compound interest.java
RummanAhmedFazil Oct 18, 2020
7d1fd79
Create Calculate compound interest
RummanAhmedFazil Oct 18, 2020
261c547
Create Program to reverse the array in Java Language
indrajitsinha88 Oct 18, 2020
8699325
Create Program to print the fibonacci series -C++
AbhiramRajeevan Oct 18, 2020
9e2cd3a
Print leap years of given range
AbhiramRajeevan Oct 18, 2020
bbe1a2c
Create Program to count vowels, consonant, digits and special charact…
indrajitsinha88 Oct 18, 2020
4cbfc2b
Create Program to find largest element in array in Java Using Eclipse
indrajitsinha88 Oct 18, 2020
2d6645e
Merge pull request #998 from Shubzedm007/patch-1
heydc7 Oct 18, 2020
e12a77b
Merge pull request #999 from aaryaab/patch-1
heydc7 Oct 18, 2020
d8f0626
Merge pull request #1000 from Pankaj6198/patch-1
heydc7 Oct 18, 2020
ccf945b
Create Simple Calculator in Bash Language Using Ubuntu Terminal
indrajitsinha88 Oct 18, 2020
55c4ee5
Merge pull request #1001 from Shubzedm007/patch-2
heydc7 Oct 18, 2020
f277f7f
Merge pull request #1002 from Addhyay/main
heydc7 Oct 18, 2020
19c279b
Merge pull request #1003 from AbhiramRajeevan/patch-1
heydc7 Oct 18, 2020
721fca9
Merge pull request #1004 from Shubzedm007/patch-3
heydc7 Oct 18, 2020
9ff032e
Merge pull request #1005 from aaryaab/patch-2
heydc7 Oct 18, 2020
6f682cc
Merge pull request #1006 from Shubzedm007/patch-4
heydc7 Oct 18, 2020
8579fb6
Merge pull request #1007 from AbhiramRajeevan/patch-2
heydc7 Oct 18, 2020
5f2de70
Merge pull request #1008 from Pankaj6198/patch-3
heydc7 Oct 18, 2020
eac9286
Merge pull request #1009 from indrajitsinha88/patch-1
heydc7 Oct 18, 2020
43f99b2
Merge pull request #1010 from AbhiramRajeevan/patch-3
heydc7 Oct 18, 2020
26e4b53
Merge pull request #1011 from RummanAhmedFazil/main
heydc7 Oct 18, 2020
99c6309
Create ProgramToMultiply2DMatrices
DivyanshuSingh2000 Oct 18, 2020
47041dd
Merge pull request #1012 from AbhiramRajeevan/patch-4
heydc7 Oct 18, 2020
89b92b7
Merge pull request #1013 from indrajitsinha88/patch-2
heydc7 Oct 18, 2020
86187cc
Merge pull request #1014 from indrajitsinha88/patch-3
heydc7 Oct 18, 2020
26542c5
Merge pull request #1015 from indrajitsinha88/patch-5
heydc7 Oct 18, 2020
3c864ee
Merge pull request #1016 from DivyanshuSingh2000/patch-3
heydc7 Oct 18, 2020
13cf009
Create PowerOfAnyNumber
DivyanshuSingh2000 Oct 18, 2020
2b4a7d9
Merge pull request #1017 from DivyanshuSingh2000/patch-4
heydc7 Oct 18, 2020
c05ac28
Create Array Reversed
technicalreju Oct 18, 2020
61d2e93
Create Difference between Sum of Square using Java
aaryaab Oct 18, 2020
c4b8574
Create ASCII value print
technicalreju Oct 18, 2020
b3de556
Create Calculator using Java
aaryaab Oct 18, 2020
129ae1b
Create Number raised to a power
namita27 Oct 18, 2020
2742cb2
Create Program to calculate the power of a number
Aswinipai Oct 18, 2020
6b4b09c
Create Merge sort
Aswinipai Oct 18, 2020
adca594
Create Fibonacci
namita27 Oct 18, 2020
ee6ff5e
Create Palindrome program in C
Ashishkhakurel Oct 18, 2020
7bb560a
Create Fibonacci Series in C
Ashishkhakurel Oct 18, 2020
ac61e92
Create Armstrong Number in C
Ashishkhakurel Oct 18, 2020
5ededda
Create DecimalToBinary
namita27 Oct 18, 2020
77ca31e
Create C Program to print Alphabet Triangle
Ashishkhakurel Oct 18, 2020
90ef05d
Create rogram to convert binary to decimal number
sakshirpriya Oct 18, 2020
73c6a78
Create Length of a string
namita27 Oct 18, 2020
6bcb286
Create bubbleSort.py
aniket170 Oct 18, 2020
9c7862d
Created Constraint Satisfaction Problem
Oct 18, 2020
7037279
Merge pull request #1018 from technicalreju/patch-2
heydc7 Oct 18, 2020
e043a27
Merge pull request #1019 from aaryaab/patch-3
heydc7 Oct 18, 2020
f4c1150
Merge pull request #1020 from technicalreju/patch-3
heydc7 Oct 18, 2020
5998ca1
Merge pull request #1021 from aaryaab/patch-4
heydc7 Oct 18, 2020
2141355
Arithmetic operations python
satishkollu Oct 18, 2020
b818e2f
Create count vowels and consonants
satishkollu Oct 18, 2020
856f80e
Create Program to find largest element in an array
Geethu1440 Oct 18, 2020
2d6b72d
Create Program to find largest element in an array
Geethu1440 Oct 18, 2020
6e42c85
Merge pull request #1022 from namita27/patch-1
heydc7 Oct 18, 2020
3990ff8
Merge pull request #1023 from Aswinipai/patch-8
heydc7 Oct 18, 2020
50fe3cc
Merge pull request #1024 from Aswinipai/patch-10
heydc7 Oct 18, 2020
8362aff
Merge pull request #1025 from namita27/patch-2
heydc7 Oct 18, 2020
381735a
Merge pull request #1026 from Ashishkhakurel/patch-1
heydc7 Oct 18, 2020
d54cf07
Merge pull request #1027 from Ashishkhakurel/patch-2
heydc7 Oct 18, 2020
fecad85
Merge pull request #1028 from Ashishkhakurel/patch-3
heydc7 Oct 18, 2020
276006f
Merge pull request #1029 from namita27/patch-3
heydc7 Oct 18, 2020
0968e0a
Create Program to find smallest element in an array
Geethu1440 Oct 18, 2020
629df0b
Merge pull request #1030 from Ashishkhakurel/patch-4
heydc7 Oct 18, 2020
0c6cd32
Merge pull request #1031 from sakshirpriya/main
heydc7 Oct 18, 2020
5b7286b
Merge pull request #1032 from namita27/patch-4
heydc7 Oct 18, 2020
82ef7dc
Create Program to find sum of all elements in an array
Geethu1440 Oct 18, 2020
32f0cae
Merge pull request #1033 from aniket170/main
heydc7 Oct 18, 2020
07ab088
Merge pull request #1034 from Addhyay/main
heydc7 Oct 18, 2020
c1fe192
Merge pull request #1035 from satishkollu/patch-2
heydc7 Oct 18, 2020
841fa61
Merge pull request #1036 from satishkollu/patch-3
heydc7 Oct 18, 2020
5125307
Merge pull request #1037 from Geethu1440/patch-1
heydc7 Oct 18, 2020
fe5e761
Merge pull request #1038 from Geethu1440/patch-2
heydc7 Oct 18, 2020
cf51162
Merge pull request #1039 from Geethu1440/patch-3
heydc7 Oct 18, 2020
7be7c1f
Merge pull request #1040 from Geethu1440/patch-4
heydc7 Oct 18, 2020
59dc30c
Create Segment trees
prabalbansal6183 Oct 18, 2020
4a303dd
Create modulus of 5
AkhilParikh Oct 18, 2020
40706f5
Create persistent Segment trees
prabalbansal6183 Oct 18, 2020
31f2463
Create Leap year
dmjogad Oct 18, 2020
f9b318d
Create binary_search_algo
satishkollu Oct 18, 2020
f7ccd47
Create LinkedHashSet Class In java
nikhilkrdwivedi Oct 18, 2020
d864989
Merge pull request #1041 from prabalbansal6183/patch-2
heydc7 Oct 18, 2020
4a97d87
Merge pull request #1042 from AkhilParikh/patch-5
heydc7 Oct 18, 2020
3d80288
Merge pull request #1043 from prabalbansal6183/patch-3
heydc7 Oct 18, 2020
4d6c32b
Merge pull request #1044 from dmjogad/patch-2
heydc7 Oct 18, 2020
9ecfa82
Merge pull request #1045 from NikhilKrDwivedi/main
heydc7 Oct 18, 2020
e26d187
Merge pull request #1046 from satishkollu/patch-4
heydc7 Oct 18, 2020
ff23694
Best first search algorithm
Oct 18, 2020
fa49da4
Added a anagram program using Java
amit14mitra Oct 18, 2020
29aa3d2
Create Fibonacci Series In C++
nikhilkrdwivedi Oct 18, 2020
1727254
Create Replace all 0(s) with 5(s) in user accepted number
NamitVarshney Oct 18, 2020
a24df76
Calcii.cs
lunatic-rohan Oct 18, 2020
466f6fd
Create Wave Print in 2D-Array
NamitVarshney Oct 18, 2020
b98885e
Create Spiral Print of a 2D Array
NamitVarshney Oct 18, 2020
7c6f25e
Create Finding nth root of a number using C++.
NamitVarshney Oct 18, 2020
9b9c2a9
Create Program to check triangle is equilateral, isosceles ot scalene
sujoypal51 Oct 18, 2020
719ae41
Merge pull request #1047 from Addhyay/main
heydc7 Oct 18, 2020
e81b5b1
Merge pull request #1048 from amit14mitra/patch-1
heydc7 Oct 18, 2020
4786733
Merge pull request #1049 from NikhilKrDwivedi/main
heydc7 Oct 18, 2020
de36481
Create Program to print ASCII value of given character with python
sujoypal51 Oct 18, 2020
e6a56f9
Merge pull request #1050 from NamitVarshney/patch-1
heydc7 Oct 18, 2020
c743e0d
Merge pull request #1051 from lunatic-rohan/main
heydc7 Oct 18, 2020
8584be6
Merge pull request #1052 from NamitVarshney/patch-2
heydc7 Oct 18, 2020
745b1ef
Merge pull request #1053 from NamitVarshney/patch-3
heydc7 Oct 18, 2020
c4d0ac4
Merge pull request #1054 from NamitVarshney/patch-4
heydc7 Oct 18, 2020
064bfed
Create Program to convert binary to octal number with python
sujoypal51 Oct 18, 2020
f4f1052
Merge pull request #1055 from sujoypal51/patch-1
heydc7 Oct 18, 2020
19d2db2
Merge pull request #1056 from sujoypal51/patch-2
heydc7 Oct 18, 2020
1191d5c
Merge pull request #1057 from sujoypal51/patch-3
heydc7 Oct 18, 2020
3d0b39a
find_lenght_of_a_string_length_in_javascript.js
allangmr Oct 19, 2020
44a519e
Create Length of String
abhishek5228 Oct 19, 2020
4b5c103
Update Binary Search Tree
parimal213 Oct 19, 2020
60f4afa
Update Program to add two numbers in pyhton
satishkollu Oct 19, 2020
7f73192
Create Program to print Fibonnaci Series new
CharlieTheHack1 Oct 19, 2020
bd69e0e
Create ProgramToCountVowelsInAStringByAnmol.cpp
anXcode Oct 19, 2020
9c34787
Rename ProgramToCountVowelsInAStringByAnmol.cpp to ProgramToCountVowe…
anXcode Oct 19, 2020
cb22b51
Create A string is palindrome or not
SurbhiPal972 Oct 19, 2020
4d58611
Create ProgramToCountVowelsInAStringRecursive.cpp
anXcode Oct 19, 2020
3369e26
Create ProgramToCountVowelsInAStringByIterative.java
anXcode Oct 19, 2020
51fdf12
Create ProgramToCountVowelsInAStringByRecursive.java
anXcode Oct 19, 2020
41060ab
Create binary search in c
kchaithanya125 Oct 19, 2020
77ed3c0
Create C program to get input from a user using scanf
kchaithanya125 Oct 19, 2020
0341993
Create using if else control instructions
kchaithanya125 Oct 19, 2020
3f4a952
Create C program to check if an integer is prime or not
kchaithanya125 Oct 19, 2020
dc7e53a
Create command line arguments in c
kchaithanya125 Oct 19, 2020
de48862
Create Array program in c
Oct 19, 2020
49ff042
Create function program inc
Oct 19, 2020
e96b14b
Create Using comments in a program in c
Oct 19, 2020
8520bf9
Create using structures in C programming
Oct 19, 2020
1bc32e5
Merge pull request #1059 from allangmr/patch-1
heydc7 Oct 19, 2020
b2672bf
Merge pull request #1060 from 0031abbhishek/patch-1
heydc7 Oct 19, 2020
d521660
Merge pull request #1061 from parimal213/patch-1
heydc7 Oct 19, 2020
4e1d6cd
Merge pull request #1063 from satishkollu/patch-5
heydc7 Oct 19, 2020
a02385f
Merge pull request #1064 from CharlieTheHack1/patch-1
heydc7 Oct 19, 2020
b49a2b8
Merge pull request #1066 from SurbhiPal972/patch-1
heydc7 Oct 19, 2020
4c089c7
Merge pull request #1067 from anXcode/main
heydc7 Oct 19, 2020
5f40525
Merge pull request #1068 from kchaithanya125/patch-1
heydc7 Oct 19, 2020
361d9f9
Merge pull request #1071 from kchaithanya125/patch-4
heydc7 Oct 19, 2020
136c3c9
Merge pull request #1069 from kchaithanya125/patch-2
heydc7 Oct 19, 2020
e82b984
Merge pull request #1070 from kchaithanya125/patch-3
heydc7 Oct 19, 2020
79008ae
Merge pull request #1072 from kchaithanya125/patch-5
heydc7 Oct 19, 2020
88ea49f
Merge pull request #1073 from GodofDaath/patch-1
heydc7 Oct 19, 2020
3f04963
Merge pull request #1074 from GodofDaath/patch-2
heydc7 Oct 19, 2020
604ec11
Merge pull request #1075 from GodofDaath/patch-3
heydc7 Oct 19, 2020
8d446cd
Merge pull request #1076 from GodofDaath/patch-4
heydc7 Oct 19, 2020
bb34fdc
elements sum in array
shiwangi123456 Oct 19, 2020
7d6b65c
factorial of no
shiwangi123456 Oct 19, 2020
28237b6
power of number
shiwangi123456 Oct 19, 2020
f2428b3
length of the string
shiwangi123456 Oct 19, 2020
11c1087
array reverse
shiwangi123456 Oct 19, 2020
3f1b06d
binary to decimal converter
shiwangi123456 Oct 19, 2020
a01b50e
multiplication of matrices
shiwangi123456 Oct 19, 2020
c293e19
matrix multiplication 2D
shiwangi123456 Oct 19, 2020
4ba8c28
Update ProgramToConvertBinaryToDecimalNumber.cpp
shiwangi123456 Oct 19, 2020
af343ae
binary to octal
shiwangi123456 Oct 19, 2020
2a4571a
fibonacci series
shiwangi123456 Oct 19, 2020
91d22bc
Create series in c
shiwangi123456 Oct 19, 2020
9af7842
simple webpage
shiwangi123456 Oct 19, 2020
d413149
Merge pull request #1 from shiwangi123456/shiwangi123456-patch-1
shiwangi123456 Oct 19, 2020
9a34856
Create Multiplication of matrix
shiwangi123456 Oct 19, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
124 changes: 124 additions & 0 deletions 01knapsack(A.V).cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#include <bits/stdc++.h>
using namespace std;

int max(int a, int b)
{
return (a > b) ? a : b;
}
int knapsack(int wt[], int val[], int W, int N, int** tb)
{
if(N<=0 || W==0)
{
return 0;
}
if(tb[N][W]!=-1)
{ //Memoization
return tb[N][W];
}

if(wt[N-1]<=W)
{
return tb[N][W]=max(val[N-1] + knapsack(wt, val, W-wt[N-1],N-1, tb), knapsack(wt, val, W, N-1, tb));
}
else if(wt[N-1]>W)
{
return tb[N][W]=knapsack(wt, val, W, N-1, tb);
}
}
int knapSackR(int W, int wt[], int val[], int n)
{
// double pointer to declare the
// table dynamically
int** dp;
dp = new int*[n];

// loop to create the table dynamically
for (int i = 0; i < n; i++)
dp[i] = new int[W + 1];

// loop to initially filled the
// table with -1
for (int i = 0; i < n; i++)
for (int j = 0; j < W + 1; j++)
dp[i][j] = -1;
return knapsack(wt, val, W, n, dp);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t,N,W,x;
cin>>t; //t=[1,100]
while(t--)
{
cin>>N; //N=[1,1000]
cin>>W; //W=[1,1000]
int wt[W]; //wt[i]=[1,1000]
int val[N]; //val[i]=[1,1000]

for (int i = 0; i <N; i++)
{
/* code */
cin>>x;
val[i]=x;
}

for (int i = 0; i <W; i++)
{
/* code */
cin>>x;
wt[i]=x;
}
int n = sizeof(val) / sizeof(val[0]);
cout << knapSackR(W, wt, val, n);
}
}

//top down approach
#include <iostream>
using namespace std;


void knap(int n, int w, int val[],int weight[])
{
int t[n+1][w+1];


//fill 0th rows and coloumns with zero.
for(int i=0;i<=n;i++)
t[i][0]=0;

for(int j=0;j<=w;j++)
t[0][j]=0;


for(int i=1;i<=n;i++)
{
for(int j=1;j<=w;j++)
{
if(j<weight[i])
t[i][j]=t[i-1][j];
else
t[i][j]=max((val[i]+t[i-1][j-weight[i]]),t[i-1][j]);
}
}

cout<<t[n][w]<<endl; //last element

}
int main() {int y; cin>>y;
while(y--)
{ int n; cin>>n;
int w; cin>>w;
int val[n];int weight[n];

for(int i=1;i<=n;i++)
cin>>val[i];

for(int i=1;i<=n;i++)
cin>>weight[i];

knap(n,w,val,weight);

}
return 0;
}
40 changes: 40 additions & 0 deletions 2D Matrices using C
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>
int main() {
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
printf("Enter the number of rows (between 1 and 100): ");
scanf("%d", &r);
printf("Enter the number of columns (between 1 and 100): ");
scanf("%d", &c);

printf("\nEnter elements of 1st matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}

printf("Enter elements of 2nd matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &b[i][j]);
}

// adding two matrices
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
sum[i][j] = a[i][j] + b[i][j];
}

// printing the result
printf("\nSum of two matrices: \n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("%d ", sum[i][j]);
if (j == c - 1) {
printf("\n\n");
}
}

return 0;
}
49 changes: 49 additions & 0 deletions 3D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
public static void main(String[] args) {
Scanner getIt = new Scanner(System.in);
System.out.println("Input 1 integer n: ");
int n = getIt.nextInt();
if (n > 0){
final double M[][][] = new double[n][n][n];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
M[i][j][k] = 3.0;
System.out.println("Input 1 integer p: ");
int p = getIt.nextInt();
if(p > 0){
for(int q = 1; q <= p; q++){
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
for (int k = 0; k < n; k++){
System.out.printf("%f ", Math.pow(matrixMult(M[i], M[i])[j][k], q));
}
System.out.println("\n");
}

}
System.out.println("xxxxxxxxxxxxxxxxxxxxx");
}
}
else{
System.out.println("Woops, you entered a negative p.");
}
}
else{
System.out.println("Woops, you entered a negative n.");
}
}

public static double[][] matrixMult(double a[][], double b[][]) {
int aRows = a.length;
int aCols = a[0].length;
int bCols = b[0].length;
double[][] result = new double[aRows][bCols];
for(int i = 0; i < aRows; i++){
for(int j = 0; j < bCols; j++){
for(int k = 0; k < aCols; k++){
result[i][j] += a[i][k] * b[k][j];
}
}
}
return result;
}
23 changes: 23 additions & 0 deletions 3_matrix_multiplication_using_numpy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np

np.random.seed(42)

A = np.random.randint(0, 10, size=(2,2))

B = np.random.randint(0, 10, size=(2,3))

C = np.random.randint(0, 10, size=(3,3))

print("Matrix A is:\n{}, shape={}\n".format(A, A.shape))

print("Matrix B is:\n{}, shape={}\n".format(B, B.shape))

print("Matrix C is:\n{}, shape={}\n".format(C, C.shape))

D = np.matmul(np.matmul(A,B), C)

print("Multiplication in the order (AB)C:\n\n{},shape={}\n".format(D, D.shape))

D = np.matmul(A, np.matmul(B,C))

print("Multiplication in the order A(BC):\n\n{},shape={}".format(D, D.shape))
8 changes: 8 additions & 0 deletions A C++ Program to print ASCII value of given character
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <iostream>
using namespace std;
int main()
{
char c = 'A';
cout << "The ASCII value of " << c << " is " << int(c);
return 0;
}
40 changes: 40 additions & 0 deletions A Program for 2D Matrices
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>
int main() {
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
printf("Enter the number of rows (between 1 and 100): ");
scanf("%d", &r);
printf("Enter the number of columns (between 1 and 100): ");
scanf("%d", &c);

printf("\nEnter elements of 1st matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &a[i][j]);
}

printf("Enter elements of 2nd matrix:\n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("Enter element a%d%d: ", i + 1, j + 1);
scanf("%d", &b[i][j]);
}

// adding two matrices
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
sum[i][j] = a[i][j] + b[i][j];
}

// printing the result
printf("\nSum of two matrices: \n");
for (i = 0; i < r; ++i)
for (j = 0; j < c; ++j) {
printf("%d ", sum[i][j]);
if (j == c - 1) {
printf("\n\n");
}
}

return 0;
}
Loading