Lädt...


🔧 Relearning Basics of CS - Implementing Stack


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

I have been trying to learn a new programming language and what better way to do it than start from the basics. In this series of posts that come I will attempt to implement a simple Data structure and algorithms using Go. 

In the book An Introduction to algorithms By CLRS in the chapter of Elementary data structure the first data structure that is being talked about is the stack.

What is a Stack

Stack is a simple data structure that is used to store a set of items. The properties of a stack are that it allows us to add an item to the top of the stack and remove from the stack so it follows a Last In First Out principle or LIFO.

The insert operation is called a Push and the remove operation is called a Pop. Since we dont want to have an empty stack pop and deal with memory errors we also implement a check for whether a Stack is empty or not. Fairly simple data structure.

Below you can find the implementation of the stack in golang. The time complexity is O(N) and space complexity of using a stack is O(1)

package main

import "fmt"

type Stack []int

func (stack *Stack) Push (value int){
    *stack = append(*stack, value)
}

func (stack *Stack) Pop () int{
    if stack.IsEmpty() {
        return 0
    }
    top := (*stack)[len(*stack)-1]
    *stack = (*stack)[:len(*stack)-1]
    return top
}

func (stack *Stack) IsEmpty() bool{
    return len(*stack) == 0
}


func main(){
    st := Stack{}
    st.Push(1)
    st.Push(2)
    fmt.Println(st.Pop())
}
...

🔧 relearning HTML


📈 29.3 Punkte
🔧 Programmierung

🔧 Day 1 - Relearning how to speak


📈 29.3 Punkte
🔧 Programmierung

🔧 Relearning Java Thread Primitives


📈 29.3 Punkte
🔧 Programmierung

🔧 Relearning Java Thread Primitives


📈 29.3 Punkte
🔧 Programmierung

🔧 Learn the Basics of Go by Building a Full Stack Web App with React and Go


📈 16.02 Punkte
🔧 Programmierung

🐧 Emulator basics: a stack and register machine


📈 16.02 Punkte
🐧 Linux Tipps

🐧 Emulator basics: a stack and register machine


📈 16.02 Punkte
🐧 Linux Tipps

🔧 Learn Full-Stack Development: Part 2 - Mastering JavaScript Basics in 10 Days


📈 16.02 Punkte
🔧 Programmierung

🔧 Stack Interview Questions: From Basics to Advanced Problem-Solving


📈 16.02 Punkte
🔧 Programmierung

🔧 Stack Interview Questions: From Basics to Advanced Problem-Solving


📈 16.02 Punkte
🔧 Programmierung

🔧 Why I choose T3 stack as the full-stack to build the react app


📈 11.76 Punkte
🔧 Programmierung

🕵️ Microsoft Windows NT 4.0/2000/XP IP Stack Stack-Based denial of service [Disputed]


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 Building Full-Stack Applications with the MERN Stack: A Comprehensive Guide


📈 11.76 Punkte
🔧 Programmierung

🕵️ FreeBSD up to 11.1 Stack Guard Stack-based privilege escalation


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 # Exploring the MERN Stack: A Journey into Full-Stack Development


📈 11.76 Punkte
🔧 Programmierung

📰 Full Stack Blues: Exploring Vulnerabilities In The MEAN Stack | UpGuard


📈 11.76 Punkte
📰 IT Security Nachrichten

🕵️ Microsoft Windows 2000 TCP/IP Stack Stack-Based denial of service


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 Move aws resources from one stack to another cloudformation stack


📈 11.76 Punkte
🔧 Programmierung

🕵️ Google Chrome up to 62 QUIC Networking Stack Stack-based memory corruption


📈 11.76 Punkte
🕵️ Sicherheitslücken

🕵️ CVE-2023-46841 | Xen Shadow Stack stack-based overflow


📈 11.76 Punkte
🕵️ Sicherheitslücken

🕵️ CVE-2022-32434 | EIP Stack Group OpENer 2.3.0 stack-based overflow (ID 374)


📈 11.76 Punkte
🕵️ Sicherheitslücken

🕵️ Microsoft Windows Server 2003 SP2 TCP/IP Stack Stack-Based memory corruption


📈 11.76 Punkte
🕵️ Sicherheitslücken

🕵️ Cisco SocialMiner TCP Stack TCP Connection Stack-based denial of service


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 MERN Stack VS MEAN Stack Which is Better?


📈 11.76 Punkte
🔧 Programmierung

🕵️ Cisco SocialMiner TCP Stack TCP Connection Stack-based Denial of Service


📈 11.76 Punkte
🕵️ Sicherheitslücken

🕵️ Brocade Fibre Channel SAN up to 7.4.2/8.1.1 IPv6 Stack Messages Stack-based denial of service


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 Stack Screen + Bottom Tab Navigation + Stack Screen


📈 11.76 Punkte
🔧 Programmierung

📰 Threat Stack partners with Liquid Web to extend the Threat Stack Oversight IDS to customers


📈 11.76 Punkte
📰 IT Security Nachrichten

🔧 The JAM Stack: The New Front-End Stack For Web Development


📈 11.76 Punkte
🔧 Programmierung

🕵️ Linux Kernel up to 4.13.1 Bluetooth Stack L2CAP Stack-based memory corruption


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 Full Stack Learning Management System (LMS) with MERN Stack: A Complete Guide


📈 11.76 Punkte
🔧 Programmierung

🕵️ Medium CVE-2021-28034: Stack dst project Stack dst


📈 11.76 Punkte
🕵️ Sicherheitslücken

🔧 The JAM Stack: The New Front-End Stack For Web Development


📈 11.76 Punkte
🔧 Programmierung

🕵️ GCC for Stack Smashing Protection libssp Stack-based memory corruption


📈 11.76 Punkte
🕵️ Sicherheitslücken

matomo