✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Se considera crearea unei liste dinamice de tip coada:
function nod(x){ this.x=x; this.urmator=null;}function inserare(){ let x=Number(prompt("Valoare x")); let q=new nod(x); if(p==null) p=q; else u.urmator=q; u=q;}function afisare(){ let q=p; while(q!=null){ console.log(q.x); q=q.urmator; }}function stergere(){ if(p!=null){ let q=p; p=q.urmator; q=null; if(p==null)u=null; }}let p=null, u=null;let c=Number(prompt("1 - inserare nod in varf, 2 - afisare lista, 3 - stergere nod din varf"));while(c==1 || c==2 || c==3){ if(c==1) inserare(); else if(c==2) afisare(); else stergere();c=Number(prompt("1 - inserare nod in varf, 2 - afisare lista, 3 - stergere nod din varf"));}Faceti asocierile (stergerea unui nod din vârful listei):