This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(start to end of array) | |
{ | |
if (current_element equals to X) | |
{ | |
print (current_index); | |
break; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int binarySearch(int low,int high,int key) | |
{ | |
while(low<=high) | |
{ | |
int mid=(low+high)/2; | |
if(a[mid]<key) | |
{ | |
low=mid+1; | |
} | |
else if(a[mid]>key) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void bubble_sort( int A[ ], int n ) { | |
int temp; | |
for(int k = 0; k< n-1; k++) { | |
// (n-k-1) is for ignoring comparisons of elements which have already been compared in earlier iterations | |
for(int i = 0; i < n-k-1; i++) { | |
if(A[ i ] > A[ i+1] ) { | |
// here swapping of positions is being done. | |
temp = A[ i ]; | |
A[ i ] = A[ i+1 ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int arr[3][5] = {{5, 12, 17, 9, 3}, {13, 4, 8, 14, 1}, {9, 6, 3, 7, 21}}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int arr[3][5]; | |
arr[0][0] = 5; | |
arr[1][3] = 14; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
// Array declaration and initialization | |
int arr[3][5] = {{5, 12, 17, 9, 3}, {13, 4, 8, 14, 1}, {9, 6, 3, 7, 21}}; | |
// Iterate over the array | |
for(int i=0; i<3; i++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const han = {firstname: "Han", lastname: "Solo"}; | |
const luke = {firstname: "Luke", lastname: "Skywalker"}; | |
const leia = {firstname: "Leia", lastname: "Organa"}; | |
const obi = {firstname: "Obi", lastname: "Wan"}; | |
const yoda = {firstname: "", lastname: "Yoda"}; | |
const people = [ | |
han, luke, leia, obi, | |
yoda, luke, leia, obi | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const han = { | |
firstname: "Han", lastname: "Solo", | |
spacecraft: "Falcon"}; | |
const luke = { | |
firstname: "Luke", lastname: "Skywalker", | |
job: "Jedi"}; | |
const leia = { | |
firstname: "Leia", lastname: "Organa", | |
gender: "female"}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
class Person { | |
constructor({ | |
firstname = '', | |
lastname = '', | |
spaceship = '', | |
job = '', | |
gender = '', | |
retired = false | |
} = {}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def factorial(x: Int): Int = { | |
// The body of the function goes here... | |
} |
OlderNewer