gs gs121 Abstract Data Types - Singly Linked Lists - Quiz No.1
gs gs121 Data Structures and Algorithms Quiz
This quiz belongs to book/course code gs gs121 Data Structures and Algorithms of gs organization. We have 169 quizzes available related to the book/course Data Structures and Algorithms. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Abstract Data Types. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
class Node { protected Node next; protected Object ele; Node(Object e,Node n) { ele = e; next = n; } public void setNext(Node n) { next = n; } public void setEle(Object e) { ele = e; } public Node getNext() { return next; } public Object getEle() { return ele; } } class SLL { Node head; int size; SLL() { size = 0; } }
public Node removeLast() { if(size == 0) return null; Node cur; Node temp; cur = head; while(cur.getNext() != null) { temp = cur; cur = cur.getNext(); } temp.setNext(null); size--; return cur; }
public void removeLast() { if(size == 0) return null; Node cur; Node temp; cur = head; while(cur != null) { temp = cur; cur = cur.getNext(); } temp.setNext(null); return cur; }
public void removeLast() { if(size == 0) return null; Node cur; Node temp; cur = head; while(cur != null) { cur = cur.getNext(); temp = cur; } temp.setNext(null); return cur; }
public void removeLast() { if(size == 0) return null; Node cur; Node temp; cur = head; while(cur.getNext() != null) { cur = cur.getNext(); temp = cur; } temp.setNext(null); return cur; }
public void function(Node node) { if(size == 0) head = node; else { Node temp,cur; for(cur = head; (temp = cur.getNext())!=null; cur = temp); cur.setNext(node); } size++; }
public void delete(int pos) { if(pos < 0) pos = 0; if(pos > size) pos = size; if( size == 0) return; if(pos == 0) head = head.getNext(); else { Node temp = head; for(int i=1; i<pos; i++) { temp = temp.getNext(); } temp.setNext(temp.getNext().getNext()); } size--; }
public void delete(int pos) { if(pos < 0) pos = 0; if(pos > size) pos = size; if( size == 0) return; if(pos == 0) head = head.getNext(); else { Node temp = head; for(int i=1; i<pos; i++) { temp = temp.getNext(); } temp.setNext(temp.getNext()); } size--; }
public void delete(int pos) { if(pos < 0) pos = 0; if(pos > size) pos = size; if( size == 0) return; if(pos == 0) head = head.getNext(); else { Node temp = head; for(int i=1; i<pos; i++) { temp = temp.getNext().getNext(); } temp.setNext(temp.getNext().getNext()); } size--; }
public void delete(int pos) { if(pos < 0) pos = 0; if(pos > size) pos = size; if( size == 0) return; if(pos == 0) head = head.getNext(); else { Node temp = head; for(int i=0; i<pos; i++) { temp = temp.getNext(); } temp.setNext(temp.getNext().getNext()); } size--; }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext(); } return size; }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { cur = cur.getNext(); size++; } return size; }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext(); } }
public int length(Node head) { int size = 0; Node cur = head; while(cur!=null) { size++; cur = cur.getNext().getNext(); } return size; }
public void insertBegin(Node node) { node.setNext(head); head = node; size++; }
public void insertBegin(Node node) { head = node; node.setNext(head); size++; }
public void insertBegin(Node node) { Node temp = head.getNext() node.setNext(temp); head = node; size++; }
public void insertBegin(Node node) { Node temp = head.getNext() node.setNext(temp); node = head; size++; }