آرین سليمان زاده
  • الرئيسية
  • المدونة
  • البودكاست
  • الفيديوهات
  • المكتبة
  • تواصل
العربيةArabic
DeutschGerman
EnglishEnglish
فارسیPersian
한국어Korean
中文Chinese
اللوحة•تواصل سريع

Languages

Choose your interface locale

ar

العربية

Arabic

de

Deutsch

German

en

English

English

fa

فارسی

Persian

ko

한국어

Korean

zh

中文

Chinese

احجز موعداً

أرسل رسالة قصيرة — سأرد في أقرب وقت ممكن.

LinkedInاستجابة سريعة
← مكتبة الخوارزميات/Data Structures/Stack
ملاحظة قراءة الخوارزمية

Stack

A stack is a LIFO structure: the last value pushed is the first value popped.

النوعبنية بياناتالفئةData Structuresالعمقمبتدئالتعقيد المعتادpush/pop O(1)
إجابة مقابلة قصيرة

ابدأ بهذا النموذج الذهني

A stack is a LIFO structure: the last value pushed is the first value popped.

01
شرح مبسط

كيف يعمل، بلا مصطلحات زائدة

01

Think of a stack of plates. You add and remove from one end only.

02

Core operations are push, pop and peek/top. With a good implementation they are O(1).

02
التنفيذ

اقرأ الخوارزمية كسلسلة من القرارات

01

Push adds to the top.

02

Pop removes and returns the top.

03

Peek reads the top without removing it.

مثال صغير لتحتفظ به في ذهنك

push(1), push(2), pop() returns 2.

تطبيق JavaScript قابل للقراءةJavaScript
class Stack {
  #items = [];
  push(value) { this.#items.push(value); }
  pop() { return this.#items.pop(); }
  peek() { return this.#items.at(-1); }
  get size() { return this.#items.length; }
}
كيف تقرأ هذا الكود

لا تحفظ الصياغة. تتبع الحالة التي تتغير في كل سطر واربطها بالثابت الموضح أعلاه.

التعقيد

push/pop O(1)

Do not quote this complexity mechanically. Ask which operation or input dimension it describes, then derive the cost from the loops, recursion depth, data-structure operations and any preprocessing assumptions.

03
متى تستخدمه

مناسب لـ

  • Undo/redo
  • Expression parsing
  • DFS and backtracking
04
أخطاء شائعة

ما الذي يسوء عادةً

  • Popping from an empty stack without handling it.
  • Using Array.shift() and accidentally making operations O(n).
كيف تشرحه في المقابلة

صيغة إجابة احترافية

Say LIFO first, then name push/pop/peek and one real use such as call stacks or parsing.

المشكلة→الفكرة الأساسية→الثابت / الحالة→Big-O→المفاضلة
فحص سريع للمقابلة

What problem does Stack solve?

A stack is a LIFO structure: the last value pushed is the first value popped.

ماذا يجب أن أذكر عن التعقيد؟

Its typical cost here is push/pop O(1), but a complete answer should connect that cost to the representation, input constraints and the dominant operations.

ما الخطأ الأكثر شيوعاً؟

Popping from an empty stack without handling it.

متابعة القراءةQueueValid ParenthesesDFS
المصدر وقراءات إضافية

كُتب هذا الدرس بشكل مستقل للدراسة الهادئة والاستعداد للمقابلات، بالاعتماد على فهرس موضوعات trekhleb/javascript-algorithms. يحتوي المستودع الأصلي على التطبيقات والاختبارات ومراجع README الخاصة بكل موضوع.

فتح المستودع الأصلي ↗
آرین سليمان زاده

معرض أعمال شخصي يركز على هندسة الويب الحديثة، وأنظمة الواجهات، ومنتجات الذكاء الاصطناعي العملية — كود نظيف، وتصميم نقي.

روابط سريعة

  • نبذة
  • المدونة
  • المكتبة
  • تواصل

تواصل

  • soleimanzadeh.a.work@gmail.com
  • soleimanzadeh.uni@gmail.com

التوفر: أيام الأسبوع

عادةً يتم الرد خلال 24 ساعة.

النشرة البريدية

احصل على تحديثات حول المقالات، والمشاريع، والإصدارات الجديدة.

© 2026 ariansoleimanzadeh.dev — جميع الحقوق محفوظة.

لينكدإن