SlideShare a Scribd company logo
1 of 5
Please add/modify the following to the original code using C#
1. DeleteFirst <-- deletes the first value from the list (if it exists!)
2. DeleteLast <-- deletes the last value from the list (if it exists!)
3. DeleteValue(given a value) <- it should delete the first occurrence (if any!) of the value in the
array list
4. Delete(given an index)
5. Reverse <-- this should reverse the list, not merely display it!
MODIFY/ADD THE CODE TO THE FOLLOWING AND PLEASE ADD MEANINGFUL
COMMENTS TO THE CODE ( I WILL BE SURE TO UPVOTE):
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace Array_Lists
{
internal class MyList<T> : IEnumerable<T>
{
//data: fields, properties
private T[] array;
public int Count { get; private set; }
public int Capacity { get { return array.Length; } }
//actions: methods
public bool IsFull()
{
//if (Count == Capacity)
// return true;
//else
// return false;
return Count == Capacity;
}
public bool IsEmpty()
{
return Count == 0;
}
public void PrintArray()//O(n)
{
for(int i= 0; i< Count; i++)
{
Console.Write(array[i] + ", ");
}
Console.WriteLine();
}
public void Insert(int index, T newValue)//O(n)
{
//validation on index
if (index < 0 || index > Count)
throw new IndexOutOfRangeException();
if (IsFull())
DoubleTheCapacity();
//shift elements to the right
for (int i = Count; i > index; i--)
{
array[i] = array[i - 1];
}
//put in your new values
array[index] = newValue;
Count++;
}
public T this[int i]
{
get {
// validation on index
if (i < 0 || i >= Count)
throw new IndexOutOfRangeException();
return array[i]; }
set {
// validation on index
if (i < 0 || i >= Count)
throw new IndexOutOfRangeException();
array[i] = value;
}
}
public void Clear()//O(1)
{
//array = new T[Capacity];
Count = 0;
}
public void AddFirst(T newValue)//O(n)
{
Insert(0, newValue);
}
public void AddLast(T newValue)//O(n) worst case, O(1) on average
{
//check if there is space in the array
if(IsFull())
{
DoubleTheCapacity();
}
//there is space in the array
array[Count] = newValue;
Count++;
}
public void Add(T newValue)
{
AddLast(newValue);
}
private void DoubleTheCapacity()
{
//create a larger array, twice capacity
T[] newArray = new T[Capacity*2];
//copy old values into the new array
for(int i=0; i< Count; i++)
{
newArray[i] = array[i];
}
//change the array to point to the new array
array = newArray;
}
public IEnumerator<T> GetEnumerator()
{
for(int i= 0; i<Count; i++)
{
yield return array[i];
}
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
public static MyList<T> operator+ (MyList<T> firstList, MyList<T> secondList)
{
MyList<T> newList = new MyList<T>(firstList.Capacity + secondList.Capacity);
foreach (var val in firstList)
newList.Add(val);
foreach (var val in secondList)
newList.Add(val);
return newList;
}
//ctors
public MyList(int initialCapacity = 1)
{
//Count = 0;
array = new T[initialCapacity];
}
public MyList(MyList<T> oldList)
{
Count = oldList.Count;
array = new T[oldList.Capacity];
for (int i = 0; i < Count; i++)
array[i] = oldList[i];
}
}
}
Please add-modify the following to the original code using C# 1- Delet.docx

More Related Content

Similar to Please add-modify the following to the original code using C# 1- Delet.docx

Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfarorastores
 
package singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdfpackage singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdfamazing2001
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfRAJATCHUGH12
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdffootstatus
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdffantoosh1
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfravikapoorindia
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructuresmartha leon
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdffathimafancyjeweller
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfSIGMATAX1
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfaksahnan
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdfsyedabdul78662
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfarpitcomputronics
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
 
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
import java-util-Iterator- import java-util-NoSuchElementException- im.pdfimport java-util-Iterator- import java-util-NoSuchElementException- im.pdf
import java-util-Iterator- import java-util-NoSuchElementException- im.pdfStewart29UReesa
 
import java.util.ArrayList;public class ArrayListADT {   public .pdf
import java.util.ArrayList;public class ArrayListADT {   public .pdfimport java.util.ArrayList;public class ArrayListADT {   public .pdf
import java.util.ArrayList;public class ArrayListADT {   public .pdfmohammadirfan136964
 
lec6.ppt
lec6.pptlec6.ppt
lec6.pptcawarir
 
In this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdfIn this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdfEvanpZjSandersony
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdfasarudheen07
 

Similar to Please add-modify the following to the original code using C# 1- Delet.docx (20)

Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdfHelp please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
Help please, I have attached LinkedList.cpp and LinkedList.hPlease.pdf
 
package singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdfpackage singlylinkedlist; public class Node { public String valu.pdf
package singlylinkedlist; public class Node { public String valu.pdf
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdfImplement the additional 5 methods as indicated in the LinkedList fi.pdf
Implement the additional 5 methods as indicated in the LinkedList fi.pdf
 
I need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdfI need help with this code working Create another project and add yo.pdf
I need help with this code working Create another project and add yo.pdf
 
ReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdfReversePoem.java ---------------------------------- public cl.pdf
ReversePoem.java ---------------------------------- public cl.pdf
 
Jhtp5 20 Datastructures
Jhtp5 20 DatastructuresJhtp5 20 Datastructures
Jhtp5 20 Datastructures
 
Please review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdfPlease review my code (java)Someone helped me with it but i cannot.pdf
Please review my code (java)Someone helped me with it but i cannot.pdf
 
Implement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdfImplement the ADT stack by using an array stack to contain its entri.pdf
Implement the ADT stack by using an array stack to contain its entri.pdf
 
So I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdfSo I have this code(StackInAllSocks) and I implemented the method but.pdf
So I have this code(StackInAllSocks) and I implemented the method but.pdf
 
package ADTs public interface CollectionADTltTgt .pdf
package ADTs public interface CollectionADTltTgt      .pdfpackage ADTs public interface CollectionADTltTgt      .pdf
package ADTs public interface CollectionADTltTgt .pdf
 
I only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdfI only need help with four methods in the EmployeeManager class the .pdf
I only need help with four methods in the EmployeeManager class the .pdf
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
import java-util-Iterator- import java-util-NoSuchElementException- im.pdfimport java-util-Iterator- import java-util-NoSuchElementException- im.pdf
import java-util-Iterator- import java-util-NoSuchElementException- im.pdf
 
import java.util.ArrayList;public class ArrayListADT {   public .pdf
import java.util.ArrayList;public class ArrayListADT {   public .pdfimport java.util.ArrayList;public class ArrayListADT {   public .pdf
import java.util.ArrayList;public class ArrayListADT {   public .pdf
 
Java Generics
Java GenericsJava Generics
Java Generics
 
lec6.ppt
lec6.pptlec6.ppt
lec6.ppt
 
In this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdfIn this homework- you will write a program modify program you wrote in.pdf
In this homework- you will write a program modify program you wrote in.pdf
 
import java-util--- public class MyLinkedList{ public static void.pdf
import java-util---  public class MyLinkedList{    public static void.pdfimport java-util---  public class MyLinkedList{    public static void.pdf
import java-util--- public class MyLinkedList{ public static void.pdf
 

More from Stewartt0kJohnstonh

please answer ASAP- I'll rate- 1- Skin is the largest organ in the b.docx
please answer ASAP- I'll rate-   1- Skin is the largest organ in the b.docxplease answer ASAP- I'll rate-   1- Skin is the largest organ in the b.docx
please answer ASAP- I'll rate- 1- Skin is the largest organ in the b.docxStewartt0kJohnstonh
 
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docx
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docxPersonnel Files Materials Marissa's Notes Team Observations Britrey -.docx
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docxStewartt0kJohnstonh
 
Phospholipids are said to be amphipathic- What does it mean to be amph.docx
Phospholipids are said to be amphipathic- What does it mean to be amph.docxPhospholipids are said to be amphipathic- What does it mean to be amph.docx
Phospholipids are said to be amphipathic- What does it mean to be amph.docxStewartt0kJohnstonh
 
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docx
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docxPERL- CREATE a function! (there needs to be a function) NO MAX- so do.docx
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docxStewartt0kJohnstonh
 
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docx
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docxPestr rocoiptsi Cash received frem customens Cash recehed from additio.docx
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docxStewartt0kJohnstonh
 
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docx
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docxSuppose the dsta represenit the inches of aaidall in Apnil loe a corta.docx
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docxStewartt0kJohnstonh
 
Suppose the data represent the inches of rainfall in Aprif for a certa.docx
Suppose the data represent the inches of rainfall in Aprif for a certa.docxSuppose the data represent the inches of rainfall in Aprif for a certa.docx
Suppose the data represent the inches of rainfall in Aprif for a certa.docxStewartt0kJohnstonh
 
Suppose the dala regresent the inctes of raintall in Apni for a certan.docx
Suppose the dala regresent the inctes of raintall in Apni for a certan.docxSuppose the dala regresent the inctes of raintall in Apni for a certan.docx
Suppose the dala regresent the inctes of raintall in Apni for a certan.docxStewartt0kJohnstonh
 
Suppose that you were provided a scholarship to attend the National Ho.docx
Suppose that you were provided a scholarship to attend the National Ho.docxSuppose that you were provided a scholarship to attend the National Ho.docx
Suppose that you were provided a scholarship to attend the National Ho.docxStewartt0kJohnstonh
 
Suppose that there are three ways to get hypertension- These ways are.docx
Suppose that there are three ways to get hypertension-  These ways are.docxSuppose that there are three ways to get hypertension-  These ways are.docx
Suppose that there are three ways to get hypertension- These ways are.docxStewartt0kJohnstonh
 
Suppose that the proportions of blood phenotypes in a particular popul.docx
Suppose that the proportions of blood phenotypes in a particular popul.docxSuppose that the proportions of blood phenotypes in a particular popul.docx
Suppose that the proportions of blood phenotypes in a particular popul.docxStewartt0kJohnstonh
 
Suppose that the probability of suffering a side effect from a certain.docx
Suppose that the probability of suffering a side effect from a certain.docxSuppose that the probability of suffering a side effect from a certain.docx
Suppose that the probability of suffering a side effect from a certain.docxStewartt0kJohnstonh
 
Suppose that the average number of Facebook friends users have is norm.docx
Suppose that the average number of Facebook friends users have is norm.docxSuppose that the average number of Facebook friends users have is norm.docx
Suppose that the average number of Facebook friends users have is norm.docxStewartt0kJohnstonh
 
Suppose that in a group of 30 people- there are 7 who test positive fo.docx
Suppose that in a group of 30 people- there are 7 who test positive fo.docxSuppose that in a group of 30 people- there are 7 who test positive fo.docx
Suppose that in a group of 30 people- there are 7 who test positive fo.docxStewartt0kJohnstonh
 
Suppose that Carlos prefers current consumption to future consumption-.docx
Suppose that Carlos prefers current consumption to future consumption-.docxSuppose that Carlos prefers current consumption to future consumption-.docx
Suppose that Carlos prefers current consumption to future consumption-.docxStewartt0kJohnstonh
 
Suppose that changes in bank regulations reduce the availability of cr.docx
Suppose that changes in bank regulations reduce the availability of cr.docxSuppose that changes in bank regulations reduce the availability of cr.docx
Suppose that changes in bank regulations reduce the availability of cr.docxStewartt0kJohnstonh
 
Suppose that autonomous consumption is 1-000 - government purchases ar.docx
Suppose that autonomous consumption is 1-000 - government purchases ar.docxSuppose that autonomous consumption is 1-000 - government purchases ar.docx
Suppose that autonomous consumption is 1-000 - government purchases ar.docxStewartt0kJohnstonh
 
Suppose that a random variable X has only two values- 0 and 10- If P(X.docx
Suppose that a random variable X has only two values- 0 and 10- If P(X.docxSuppose that a random variable X has only two values- 0 and 10- If P(X.docx
Suppose that a random variable X has only two values- 0 and 10- If P(X.docxStewartt0kJohnstonh
 
Suppose that A and B are independent events such that P ()-0-40 and P.docx
Suppose that A and B are independent events such that P ()-0-40 and P.docxSuppose that A and B are independent events such that P ()-0-40 and P.docx
Suppose that A and B are independent events such that P ()-0-40 and P.docxStewartt0kJohnstonh
 
Suppose that 57- of the women who gave birth at a certain hospital las.docx
Suppose that 57- of the women who gave birth at a certain hospital las.docxSuppose that 57- of the women who gave birth at a certain hospital las.docx
Suppose that 57- of the women who gave birth at a certain hospital las.docxStewartt0kJohnstonh
 

More from Stewartt0kJohnstonh (20)

please answer ASAP- I'll rate- 1- Skin is the largest organ in the b.docx
please answer ASAP- I'll rate-   1- Skin is the largest organ in the b.docxplease answer ASAP- I'll rate-   1- Skin is the largest organ in the b.docx
please answer ASAP- I'll rate- 1- Skin is the largest organ in the b.docx
 
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docx
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docxPersonnel Files Materials Marissa's Notes Team Observations Britrey -.docx
Personnel Files Materials Marissa's Notes Team Observations Britrey -.docx
 
Phospholipids are said to be amphipathic- What does it mean to be amph.docx
Phospholipids are said to be amphipathic- What does it mean to be amph.docxPhospholipids are said to be amphipathic- What does it mean to be amph.docx
Phospholipids are said to be amphipathic- What does it mean to be amph.docx
 
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docx
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docxPERL- CREATE a function! (there needs to be a function) NO MAX- so do.docx
PERL- CREATE a function! (there needs to be a function) NO MAX- so do.docx
 
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docx
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docxPestr rocoiptsi Cash received frem customens Cash recehed from additio.docx
Pestr rocoiptsi Cash received frem customens Cash recehed from additio.docx
 
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docx
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docxSuppose the dsta represenit the inches of aaidall in Apnil loe a corta.docx
Suppose the dsta represenit the inches of aaidall in Apnil loe a corta.docx
 
Suppose the data represent the inches of rainfall in Aprif for a certa.docx
Suppose the data represent the inches of rainfall in Aprif for a certa.docxSuppose the data represent the inches of rainfall in Aprif for a certa.docx
Suppose the data represent the inches of rainfall in Aprif for a certa.docx
 
Suppose the dala regresent the inctes of raintall in Apni for a certan.docx
Suppose the dala regresent the inctes of raintall in Apni for a certan.docxSuppose the dala regresent the inctes of raintall in Apni for a certan.docx
Suppose the dala regresent the inctes of raintall in Apni for a certan.docx
 
Suppose that you were provided a scholarship to attend the National Ho.docx
Suppose that you were provided a scholarship to attend the National Ho.docxSuppose that you were provided a scholarship to attend the National Ho.docx
Suppose that you were provided a scholarship to attend the National Ho.docx
 
Suppose that there are three ways to get hypertension- These ways are.docx
Suppose that there are three ways to get hypertension-  These ways are.docxSuppose that there are three ways to get hypertension-  These ways are.docx
Suppose that there are three ways to get hypertension- These ways are.docx
 
Suppose that the proportions of blood phenotypes in a particular popul.docx
Suppose that the proportions of blood phenotypes in a particular popul.docxSuppose that the proportions of blood phenotypes in a particular popul.docx
Suppose that the proportions of blood phenotypes in a particular popul.docx
 
Suppose that the probability of suffering a side effect from a certain.docx
Suppose that the probability of suffering a side effect from a certain.docxSuppose that the probability of suffering a side effect from a certain.docx
Suppose that the probability of suffering a side effect from a certain.docx
 
Suppose that the average number of Facebook friends users have is norm.docx
Suppose that the average number of Facebook friends users have is norm.docxSuppose that the average number of Facebook friends users have is norm.docx
Suppose that the average number of Facebook friends users have is norm.docx
 
Suppose that in a group of 30 people- there are 7 who test positive fo.docx
Suppose that in a group of 30 people- there are 7 who test positive fo.docxSuppose that in a group of 30 people- there are 7 who test positive fo.docx
Suppose that in a group of 30 people- there are 7 who test positive fo.docx
 
Suppose that Carlos prefers current consumption to future consumption-.docx
Suppose that Carlos prefers current consumption to future consumption-.docxSuppose that Carlos prefers current consumption to future consumption-.docx
Suppose that Carlos prefers current consumption to future consumption-.docx
 
Suppose that changes in bank regulations reduce the availability of cr.docx
Suppose that changes in bank regulations reduce the availability of cr.docxSuppose that changes in bank regulations reduce the availability of cr.docx
Suppose that changes in bank regulations reduce the availability of cr.docx
 
Suppose that autonomous consumption is 1-000 - government purchases ar.docx
Suppose that autonomous consumption is 1-000 - government purchases ar.docxSuppose that autonomous consumption is 1-000 - government purchases ar.docx
Suppose that autonomous consumption is 1-000 - government purchases ar.docx
 
Suppose that a random variable X has only two values- 0 and 10- If P(X.docx
Suppose that a random variable X has only two values- 0 and 10- If P(X.docxSuppose that a random variable X has only two values- 0 and 10- If P(X.docx
Suppose that a random variable X has only two values- 0 and 10- If P(X.docx
 
Suppose that A and B are independent events such that P ()-0-40 and P.docx
Suppose that A and B are independent events such that P ()-0-40 and P.docxSuppose that A and B are independent events such that P ()-0-40 and P.docx
Suppose that A and B are independent events such that P ()-0-40 and P.docx
 
Suppose that 57- of the women who gave birth at a certain hospital las.docx
Suppose that 57- of the women who gave birth at a certain hospital las.docxSuppose that 57- of the women who gave birth at a certain hospital las.docx
Suppose that 57- of the women who gave birth at a certain hospital las.docx
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

Please add-modify the following to the original code using C# 1- Delet.docx

  • 1. Please add/modify the following to the original code using C# 1. DeleteFirst <-- deletes the first value from the list (if it exists!) 2. DeleteLast <-- deletes the last value from the list (if it exists!) 3. DeleteValue(given a value) <- it should delete the first occurrence (if any!) of the value in the array list 4. Delete(given an index) 5. Reverse <-- this should reverse the list, not merely display it! MODIFY/ADD THE CODE TO THE FOLLOWING AND PLEASE ADD MEANINGFUL COMMENTS TO THE CODE ( I WILL BE SURE TO UPVOTE): using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace Array_Lists { internal class MyList<T> : IEnumerable<T> { //data: fields, properties private T[] array; public int Count { get; private set; } public int Capacity { get { return array.Length; } } //actions: methods public bool IsFull() { //if (Count == Capacity) // return true; //else // return false; return Count == Capacity; }
  • 2. public bool IsEmpty() { return Count == 0; } public void PrintArray()//O(n) { for(int i= 0; i< Count; i++) { Console.Write(array[i] + ", "); } Console.WriteLine(); } public void Insert(int index, T newValue)//O(n) { //validation on index if (index < 0 || index > Count) throw new IndexOutOfRangeException(); if (IsFull()) DoubleTheCapacity(); //shift elements to the right for (int i = Count; i > index; i--) { array[i] = array[i - 1]; } //put in your new values array[index] = newValue; Count++; } public T this[int i] { get { // validation on index if (i < 0 || i >= Count) throw new IndexOutOfRangeException(); return array[i]; } set { // validation on index if (i < 0 || i >= Count) throw new IndexOutOfRangeException(); array[i] = value;
  • 3. } } public void Clear()//O(1) { //array = new T[Capacity]; Count = 0; } public void AddFirst(T newValue)//O(n) { Insert(0, newValue); } public void AddLast(T newValue)//O(n) worst case, O(1) on average { //check if there is space in the array if(IsFull()) { DoubleTheCapacity(); } //there is space in the array array[Count] = newValue; Count++; } public void Add(T newValue) { AddLast(newValue); } private void DoubleTheCapacity() { //create a larger array, twice capacity T[] newArray = new T[Capacity*2]; //copy old values into the new array for(int i=0; i< Count; i++) { newArray[i] = array[i]; } //change the array to point to the new array array = newArray; }
  • 4. public IEnumerator<T> GetEnumerator() { for(int i= 0; i<Count; i++) { yield return array[i]; } } IEnumerator IEnumerable.GetEnumerator() { throw new NotImplementedException(); } public static MyList<T> operator+ (MyList<T> firstList, MyList<T> secondList) { MyList<T> newList = new MyList<T>(firstList.Capacity + secondList.Capacity); foreach (var val in firstList) newList.Add(val); foreach (var val in secondList) newList.Add(val); return newList; } //ctors public MyList(int initialCapacity = 1) { //Count = 0; array = new T[initialCapacity]; } public MyList(MyList<T> oldList) { Count = oldList.Count; array = new T[oldList.Capacity]; for (int i = 0; i < Count; i++) array[i] = oldList[i]; } } }