C# is the language
|
Function Name |
Function Parameters |
Description |
|
Empty |
- |
Return true if empty else return false. |
|
Size |
- |
Return the current size of the list. |
|
Insert |
Value |
Insert the Value at the end of the list. |
|
Insert |
Index, Value |
Insert the Value at the specified Index. If the Index is out of range then insert the Value at the end of the list. |
|
Remove |
Value |
Remove all elements that has the same value as Value. |
|
RemoveAt |
Index |
Remove all elements that has the same index as Index. |
|
RemoveAll |
- |
Remove all elements from the list. |
|
Search |
Value |
Return quantity of the elements that has the same value as Value. |
|
Sort |
- |
Sort the list by an ascending order. |
|
Sort |
AscendingOrder |
If AscendingOrder is true then Sort the list by an ascending order else sort the list by a descending order. |
|
IndexOf |
Value |
Return the index of the first element found with an ascending search order that has the same value as Value. If the value is not found return -1 |
|
IndexOf |
Value, AscendingOrder |
Return the index of the first element found with the same value as Value. If AscendingOrder is true then search with ascending order. Otherwise, search with a descending order. If the value is not found, return -1 |
.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chegg
{
class LinkedList
{
public string StudentName;
static void Main(string[] args)
{
List<string> linkedLists = new List<string>();
//Return true if empty else return false.
if (!linkedLists.Any())
{
Console.WriteLine(true);
}
else
{
Console.WriteLine(false);
}
//Return the current size of the list.
Console.WriteLine("Size " + linkedLists.Count);
//Insert the Value at the end of the list.
linkedLists.Add("Srikanth");
linkedLists.Add("Srikanth");
linkedLists.Add("Rahul");
//Insert the Value at the specified Index.
linkedLists.Insert(0,"Suraj");
//Remove all elements that has the same value as Value.
linkedLists.RemoveAll(CheckCondtion);
//Remove element at given index specified
linkedLists.RemoveAt(1);
//Remove all elements from the list.
linkedLists.Clear();
//Return quantity of the elements that has the same value as
Value.
int qty = linkedLists.FindAll(t =>
t.Equals("Srikanth")).Count;
//Sort the list by an ascending order.
linkedLists.Sort();
//Return the index of the first element found with an ascending
search order that has the same value as Value. If the value is not
found return -1
linkedLists.IndexOf("Rahul");
Console.ReadLine();
}
private static bool CheckCondtion(string student)
{
if (student == "Srikanth")
return true;
else
return false;
}
}
}
C# is the language Create a generic class called “LinkedList” and implement the singly linked list....
PYTHON
--------------------------------------------------------
class LinkedList:
def __init__(self):
self.__head = None
self.__tail = None
self.__size = 0
# Return the head element in the list
def getFirst(self):
if self.__size ==
0:
return
None
else:
return
self.__head.element
# Return the last element in the list
def getLast(self):
if self.__size ==
0:
return
None
else:
return
self.__tail.element
# Add an element to the beginning of the
list
def addFirst(self, e):
newNode = Node(e) #
Create a new node
newNode.next =
self.__head # link...
Given a singly-linked list interface and linked list node class, implement the singly-linked list which has the following methods in Java: 1. Implement 3 add() methods. One will add to the front (must be O(1)), one will add to the back (must be O(1)), and one will add anywhere in the list according to given index (must be O(1) for index 0 and O(n) for all other indices). They are: void addAtIndex(int index, T data), void addToFront(T data), void addToBack(T...
LinkedListBox Patterned after the ArrayBox assignment, please create your own implementation of LinkedList called LinkedListBox as explained in class. Refer to the class slides on linked lists. Specifically, implement your generic classes as: public class LinkedListNode { public E element; public LinkedListNode next; } public class LinkedListBox { public LinkedListNode head; public LinkedListNode tail; public int count = 0; } Within the LinkedListBox class, implement the following methods: public boolean add(E e). Returns true after adding an element to the...
I need help Writing a Python code!!! Implement an ordered list using doubly linked list Implement the following operations for an ordered list of integers ordered in ascending order using a doubly linked list. The “head” of the list be where the “smallest items are and let “tail” be where the largest items are. You may use whatever mechanism you like to keep track of the head and tail of the list. E.g. references or sentinel nodes. • OrderedList ()...
Implement an application based on a singly linked list that maintains a list of the top five performers in a video game. An entry on the list consists of a name and a score (you can make this into a blueprint class if you like), and the list must be maintained in descending order of scores. Here is an example of such a list when it only has three elements. Spike120 Whiz105 G-man 99 Use a class based on singly...
Q) Modify the class Linked List below to make it a Doubly Linked List. Name your class DoublyLinkedList. Add a method addEnd to add an integer at the end of the list and a method displayInReverse to print the list backwards. void addEnd(int x): create this method to add x to the end of the list. void displayInReverse(): create this method to display the list elements from the last item to the first one. Create a main() function to test...
how to implement a linked list object using only singly linked list toolkit. Then implement a FREQUENCY function to count the ovcurrence of each element in the list. task#1: Add = operator to node: implement the assignment operator for the node such that setting a node = overwrites the value in the node with the value. task#2:Linked List class implement the methods of linked list. insert search and locate remove node* operator [] task#3: Implement the Frequency
Implement a c++ 'List' class to handle a list with general operations. That means you can insert and delete any element anywhere in the list. The list has no order, except for the order you insert or delete. The methods you are to implement are as given: Constructor methods (two, default and copy constructor, a list to a newly defined list, ie 'List listA(listB)' ) empty returns true or false if list is empty or not. front makes current position...
Write a generic array list class. Task Description Your goal for this lab is to write a generic ArrayList class similar to the one in the given lecture notes on array lists. The ArrayList Class The public constructors and methods required for the ArrayList class are listed here. The type E is the generic type of an element of the list. ArrayList() Construct an empty ArrayList object. int size() Return the size (number of items) in this ArrayList. boolean isEmpty()...