SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 

Kürzlich hochgeladen (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

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]; } } }