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
interface IDuck{ | |
walk():void; | |
quack():void; | |
} | |
class Duck implements IDuck{ | |
walk():void { | |
console.log("Duck walk"); | |
} |
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 Pelican { | |
walk() { | |
console.log("Pelican walk"); | |
} | |
quack() { | |
console.log("Pelican quack"); | |
} | |
dive() { |
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
let book = { | |
name: "Harry Potter 1", | |
price: { | |
value: 50, | |
currency: "EUR" | |
}, | |
ISBN: "978-7-7058-9615-2", | |
weight: { | |
version1: { | |
value: 550, |
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
let book = { | |
name: "Harry Potter 1", | |
price: { | |
value: 50, | |
currency: "EUR" | |
}, | |
ISBN: "978-7-7058-9615-2", | |
weight: { | |
version1: { | |
value: 550, |
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
Node search(int key){ | |
Node temp = head; | |
while(temp != null){ | |
if(temp.key == key){ | |
return temp; | |
} | |
temp = temp.next; | |
} | |
return null; | |
} |
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 deleteNode(int position) { | |
if (head == null) | |
return; | |
Node temp = head; | |
if (position == 0) { | |
head = temp.next; | |
return; | |
} |
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
public void insertAfter(Node prev_node, int new_data) { | |
if (prev_node == null) { | |
System.out.println("The given previous node cannot be null"); | |
return; | |
} | |
Node new_node = new Node(new_data); | |
new_node.next = prev_node.next; | |
prev_node.next = new_node; | |
} |
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
public void insertAtEnd(int new_data) { | |
Node new_node = new Node(new_data); | |
if (head == null) { | |
head = new Node(new_data); | |
return; | |
} | |
new_node.next = null; |
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
public void insertAtBeginning(int new_data) { | |
// insert the data | |
Node new_node = new Node(new_data); | |
new_node.next = head; | |
head = new_node; | |
} |
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 LinkedList{ | |
Node head; // head of list | |
public LinkedList(){ | |
head=null; | |
} | |
public boolean isEmpty(){ | |
return head==null; | |
} | |
} |
NewerOlder