“To sustain the United States’ technology leadership in the face of China’s formidable economic and military challenge,” write Graham Allison, a professor of government at the Harvard Kennedy School and Eric Schmidt, former CEO and executive chairman of Google in Foreign Policy,“U.S. President Joe Biden should launch an urgent drive to recruit and retain 1 million tech superstars from around the world by the end of his first term in office.”
For the want of a green card (or: How the 5G story could’ve been very different)
In 2009, Erdal Arikan, a Turkish graduate of the California Institute of Technology and MIT published a paper that solved a big information theory problem. He could’ve continued his work in the U.S., but he had to leave because he couldn’t get an academic appointment or sponsorship to stay. He returned to Turkey, turned to China, and Huawei — yes, that Huawei — used his work to create 5G solutions.
The article sums us the situation like so:
And while Huawei has produced one-third of the 5G infrastructure now operating around the world, the United States does not have a single major company competing in this race. Had the United States been able to retain Arikan—simply by allowing him to stay in the country instead of making his visa contingent on immediately finding a sponsor for his work—this history might well have been different.
China’s leader Xi Jinping said it himself: “technological innovation has become the main battleground of the global playing field, and competition for tech dominance will grow unprecedentedly fierce.”
In 2001, China was still behind technologically. But in the space of only a couple of decades, they’ve leapfrogged the West in communications, facial and voice recognition, other aspects of AI, and green technology, and their education system is producing four times the STEM bachelor’s degrees and twice as many graduate degrees.
Their insularity remains their Achilles’ heel. They naturalize fewer than 100 citizens a year, while the U.S. does so with 1 million a year. That’s a difference of four orders of magnitude.
I deliberately included German-born Peter Thiel in the list particularly because he spends a lot of time canoodling with the anti-immigrant crowd. He’s one of those people who says “Ever since my family came to this country, we’ve had nothing but trouble from the immigrants.”
Let’s also not forget that Apple founder Steve Jobs was the son of a Syrian immigrant, and that there are many children of immigrants who’ve contributed so much.
“It’s time for the United States to poach with purpose.”
That’s what Allison and Schmidt write, and what they mean is that the U.S. should:
Grant an additional quarter million green cards every year.
Eliminate the rule that limits the percentage of green cards issued to citizens of any single country to 7%.
Move the immigration system from its current paper forms-based process to a digital one, which has caused more than 300,000 green cards to be lost.
Grant 100,000 additional visas to extraordinary tech talents. You know, like the one Melania Trump got, but give them to people who actually merit them.
Adjust the criteria for visas so that people qualify based on their technological expertise.
Direct the Labor Department to make recruiting STEM talent a top priority.
…and most importantly:
Dismantle the Trump administration rules whose goal was to reduce legal immigration to the U.S.
And hey, if you’re in Tampa Bay and looking for an example of a highly-skilled green card holder who’s making a difference, let me point you to the handsome well-dressed gentleman in the photo below:
Don’t let my accent, grasp of the culture, or accordion skill fool you — I’m a first-generation green card holder from the Philippines, and I’m here to make a difference in the tech world, locally and nationally.
Unlike those recipe sites where you have to scroll past lots of backstory and unrelated personal trivia before you get to the actual recipe, I’m going to give you the advice first.
It’s just this: in a hackathon, simple and working beats complex and non-functional.
The demo you build should be all about showing your main idea in action. The user should be able to go to your site or launch the application, use it to perform the intended task or achieve the intended result, and there should be a clear sign that the user succeeded at the end. That’s it. Anything else is gold-plating, and you don’t have time for that in a hackathon, whether you’re allotted an afternoon or, as in the case of StartupBus, three days. On a bus. With lots of interruptions.
Once again, I repeat my best hackathon advice: simple and working beats complex and non-functional.
Want to join StartupBus Florida?
It’s not too late to register to register for StartupBus Florida, which departs Tampa on the morning of Wednesday, July 27 and arrives in Austin, Texas on Friday, July 29 with surprises aplenty in between.
While on the road for three days, you’ll build a startup and its supporting application. Then on Saturday, July 30 and Sunday, July 31 in Austin, you’ll present your startup and application to judges in the semifinals (Saturday) and finals (Sunday).
Here’s a story from a hackathon where I applied this principle and impressed the judges enough for them to make up a new prize category on the spot.
In 2017, GM (yes, the auto manufacturer) held “Makers Hustle Harder” hackathons in a handful of cities to see what people could build on their Next Generation Infotainment (NGI) SDK for in-car console systems.
They held one of these hackathons in Tampa at Tampa Hackerspace. and I offered to help Chris Woodard work on his app idea. I did that for most of the day, and with a couple of hours left, I came up with a goofy idea that I could whip up in very little time.
A little technical background
The NGI SDK made it possible for developers to write apps for the in-car infotainment consoles located in many GM vehicle center dashboards, like the one pictured above. The SDK gives you access to:
An 800-pixel high by 390-pixel wide touchscreen to receive input from and display information to the user
The voice system to respond to user commands and provide spoken responses to the user
Data from nearly 400 sensors ranging from the state of controls (buttons and the big dial) to instrumentation (such as speed, trip odometer, orientation) to car status information (Are there passengers in the car? Are the windows open or closed?) and more.
The navigation system to get and set navigation directions
The media system to play or stream audio files
The file system to create, edit, and delete files on the system
An inter-app communication system so that apps can send messages to each other
With the SDK, developers could build and test apps for GM cars on your their own computers. It came with an emulator that lets you see your apps as they would appear on the car’s display, simulate sensor readings, and debug your app with a specialized console.
The hackathon
I arrived at Tampa Hackerspace that morning, and it was already abuzz with activity:
Outside in the parking lot were 3 NGI-equipped GM vehicles provided by Crown, a local auto dealer. Two of them were Buick Lacrosse sedans…
…and one was a GM Sierra truck:
The NGI team were there to answer our questions and help us install our apps onto the in-car console to give them some non-emulator, on-the-real-thing testing.
I performed a “smoke test” on my test app, Shotgun (an app that takes a list of names and randomly decides which one gets to “ride shotgun”) early in the morning on the Sierra’s console…
…and I have to say that there’s nothing like the feeling when your code runs for the first time on a completely new-to-you platform.
My main reason for being there was to help out Chris Woodard (whom I knew from his Cocoa / iOS programming Meetup group) on WeatherEye, his app that provides live weather reports for your planned route as you drove. When we completed it early in the afternoon, I ran a smoke test on it, and it worked as well.
With a couple of hours of “hacking time” left, I came up with a silly idea and coded it up: a timer for the game classically known as the “Chinese Fire Drill”. Here’s how it worked:
Four people get in the car, close the doors, and someone starts the app. They’ll see this screen:
When everyone’s ready, someone in the front presses the start button.
If any of the doors are open when the start button is pressed, the players will be told to close all the doors first:
If all the doors are closed when the start button is pressed, the game begins. The screen looks like this:
Players exit the car, run around it once, return to their original seat, and close their doors.
The game ends when all four doors are closed, at which point the time it took them to complete the drill is displayed:
The app wasn’t pretty, but that’s not what hackathons are about — they’re about getting your idea to work in the time allotted. Remember: simple and working beats complex and non-functional.
Everyone who built a project presented it at the end of the day to the panel of judges, and the organizers saved Fitness Fire Drill for the very end — it got a lot of laughs.
In the end…
My wife Anitra was flying out early the following morning on business, so rather than stay for the hackathon dinner and judges’ results, I high-tailed it home to have dinner with her. Before going to bed, I noticed that Chris had sent me an email telling me that Fitness Fire Drill won the “Judges’ Fetish” prize (a category they’d made up just for my submission), something I wasn’t expecting!
From that outcome, I learned what I now call the First Rule of Hackathons: simple and working beats complex and non-functional.
A linked list is a data structure that holds data as a list of items in a specific order. Each item in the list is represented by a node, which “knows” two things:
Its data
Where the next node is
Here’s a picture of a node’s structure:
Linked lists are created by connecting nodes together, as shown in the diagram below for a list containing the characters a, b, c, and d in that order:
The diagram above features the following:
Four nodes, each one for a letter in the list.
A variable called head, which is a pointer or reference to the first item in the list. It’s the entry point to the list, and it’s a necessary part of the list — you can’t access a linked list if you can’t access its head.
An optional variable called tail, which is a pointer or reference to the last item in the list. It’s not absolutely necessary, but it’s convenient if you use the list like a queue, where the last element in the list is also the last item that was added to the list.
The JavaScript version of the previous article’s code
In the previous article, I provided code for the Node and LinkedList classes in Python. As promised, here are those classes implemented in JavaScript.
// JavaScript
class Node {
constructor(data) {
this.data = data
this.next = null
}
toString() {
return this.data.toString()
}
}
class LinkedList {
constructor() {
this.head = null
}
toString() {
let output = ""
let currentNode = this.head
while (currentNode) {
output += `${currentNode.data.toString()}\n`
currentNode = currentNode.next
}
toString() {
if (!this.head) {
return('Empty list.')
}
let output = ""
let currentNode = this.head
while (currentNode) {
output += `${currentNode.data.toString()}\n`
currentNode = currentNode.next
}
return output.trim()
}
addLast(data) {
let newNode = new Node(data)
// If the list is empty,
// point `head` to the newly-added node
// and exit.
if (this.head === null) {
this.head = newNode
return
}
// If the list isn’t empty,
// traverse the list by going to each node’s
// `next` node until there isn’t a `next` node...
let currentNode = this.head
while (currentNode.next) {
currentNode = currentNode.next
}
// If you’re here, `currentNode` is
// the last node in the list.
// Point `currentNode` at
// the newly-added node.
currentNode.next = newNode
}
}
…where each item in a list is represented by the node. A node knows only about the data it contains and where the next node in the list is.
The JavaScript version of Node and LinkedList uses the same algorithms as the Python version. The Python version follows the snake_case naming convention, while the JavaScript version follows the camelCase convention.
The JavaScript LinkedList class has the following members:
head: A property containing a pointer or reference to the first item in the list, or null if the list is empty. This property has the same name in the Python version.
constructor(): The class constructor, which initializes head to null, meaning that any newly created LinkedList instance is an empty list. In the Python version, the __init__() method has this role.
toString(): Returns a string representation of the contents of the linked list for debugging purposes. If the list contains at least one item, it returns the contents of the list. If the list is empty, it returns the string Empty list. In the Python version, the __str__() method has this role.
addLast(): Given a value, it creates a new Node containing that value and adds that Node to the end of the list. In the Python version, the add_last() method has this role.
Adding more functionality to the list
In this article, we’re going to add some much-needed additional functionality to the LinkedList class, namely:
Reporting how many elements are in the list
Getting the value of the nth item in the list
Setting the value of the nth item in the list
I’ll provide both Python and JavaScript implementations.
How many elements are in the list?
To find out how many elements are in a linked list, you have to start at its head and “step through” every item in the list by following each node’s next property, keeping a count of each node you visit. When you reach the last node — the one whose next property is set to None in Python or null in JavaScript — report the number of nodes you counted.
The Python version uses one of its built-in “dunder” (Pythonese for double-underscore) methods, __len__(), to report the number of items in the list. Defining __len__() for LinkedList means that any LinkedList instance will report the number of items it contains when passed as an argument to the built-in len() function. For example, if a LinkedList instance named my_list contains 5 items, len(my_list) returns the value 5.
Here’s the Python version, which you should add to the Python version of LinkedList:
# Python
def __len__(self):
count = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve gone past the last node.
while current_node:
current_node = current_node.next
count += 1
return count
The JavaScript version is getCount(). If a LinkedList instance named myList contains 5 items, len(myList) returns the value 5.
Here’s the JavaScript version, which you should add to the JavaScript version of LinkedList:
// JavaScript
getCount() {
let count = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve gone past the last node.
while (currentNode) {
currentNode = currentNode.next
count++
}
return count
}
How do I get the data at the nth node in the list?
To get the data at the nth node of the list, you can use an approach that’s similar to the one for counting the list’s elements. You have to start at the head and “step through” every item in the list by following each node’s next property, keeping a count of each node you visit and comparing it against n, where n is the index of the node whose data you want. When the count of nodes you’ve visited is equal to n, report the data contained within the current node.
Here’s the Python version, get_element_at(), which you should add to the Python version of LinkedList:
# Python
def get_element_at(self, index):
current_index = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve reached the specified node.
while current_node:
if current_index == index:
# We’re at the node at the given index!
return current_node.data
# We’re not there yet...
current_node = current_node.next
current_index += 1
# If you’re here, the given index is larger
# than the number of elements in the list.
return None
Here’s the JavaScript version, getElementAt(), which you should add to the JavaScript version of LinkedList:
// JavaScript
getElementAt(index) {
let currentIndex = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve reached the specified node.
while (currentNode) {
if (currentIndex === index) {
// We’re at the node at the given index!
return currentNode.data
}
// We’re not there yet...
currentNode = currentNode.next
currentIndex++
}
// If you’re here, the given index is larger
// than the number of elements in the list.
return null
}
How do I set the value of the nth node in the list?
To set the data at the nth node of the list, you can use an approach that’s similar to the one for getting the data at the nth node. You have to start at the head and “step through” every item in the list by following each node’s next property, keeping a count of each node you visit and comparing it against n, where n is the index of the node whose data you want. When the count of nodes you’ve visited is equal to n, set the current node’s data property to the new value.
Here’s the Python version, set_element_at(), which you should add to the Python version of LinkedList:
# Python
def set_element_at(self, index, value):
current_index = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve reached the specified node.
while current_node:
if current_index == index:
# We’re at the node at the given index!
current_node.data = value
return True
# We’re not there yet...
current_node = current_node.next
current_index += 1
# If you’re here, the given index is larger
# than the number of elements in the list.
return False
Here’s the JavaScript version, setElementAt(), which you should add to the JavaScript version of LinkedList:
// JavaScript
setElementAt(index, value) {
let currentIndex = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve reached the specified node.
while (currentNode) {
if (currentIndex === index) {
// We’re at the node at the given index!
currentNode.data = value
return true
}
// We’re not there yet...
currentNode = currentNode.next
currentIndex++
}
// If you’re here, the given index is larger
// than the number of elements in the list.
return false
}
The classes so far
Let’s take a look at the complete Node and LinkedList classes so far, in both Python and JavaScript.
Python
# Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
def __str__(self):
return f"{self.data}"
class LinkedList:
def __init__(self):
self.head = None
def __str__(self):
if self.head is None:
return('Empty list.')
result = ""
current_node = self.head
while current_node:
result += f'{current_node}\n'
current_node = current_node.next
return result.strip()
def add_last(self, value):
new_node = Node(value)
# If the list is empty,
# point `head` to the newly-added node
# and exit.
if self.head is None:
self.head = new_node
return
# If the list isn’t empty,
# traverse the list by going to each node’s
# `next` node until there isn’t a `next` node...
current_node = self.head
while current_node.next:
current_node = current_node.next
# If you’re here, `current_node` is
# the last node in the list.
# Point `current_node` at
# the newly-added node.
current_node.next = new_node
def __len__(self):
count = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve gone past the last node.
while current_node:
current_node = current_node.next
count += 1
return count
def get_element_at(self, index):
current_index = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve reached the specified node.
while current_node:
if current_index == index:
# We’re at the node at the given index!
return current_node.data
# We’re not there yet...
current_node = current_node.next
current_index += 1
# If you’re here, the given index is larger
# than the number of elements in the list.
return None
def set_element_at(self, index, value):
current_index = 0
current_node = self.head
# Traverse the list, keeping count of
# the nodes that you visit,
# until you’ve reached the specified node.
while current_node:
if current_index == index:
# We’re at the node at the given index!
current_node.data = value
return True
# We’re not there yet...
current_node = current_node.next
current_index += 1
# If you’re here, the given index is larger
# than the number of elements in the list.
return False
JavaScript
// JavaScript
class Node {
constructor(data) {
this.data = data
this.next = null
}
toString() {
return this.data.toString()
}
}
class LinkedList {
constructor() {
this.head = null
}
toString() {
if (!this.head) {
return('Empty list.')
}
let output = ""
let currentNode = this.head
while (currentNode) {
output += `${currentNode.data.toString()}\n`
currentNode = currentNode.next
}
return output.trim()
}
addLast(value) {
let newNode = new Node(value)
// If the list is empty,
// point `head` to the newly-added node
// and exit.
if (this.head === null) {
this.head = newNode
return
}
// If the list isn’t empty,
// traverse the list by going to each node’s
// `next` node until there isn’t a `next` node...
let currentNode = this.head
while (currentNode.next) {
currentNode = currentNode.next
}
// If you’re here, `currentNode` is
// the last node in the list.
// Point `currentNode` at
// the newly-added node.
currentNode.next = newNode
}
getCount() {
let count = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve gone past the last node.
while (currentNode) {
currentNode = currentNode.next
count++
}
return count
}
getElementAt(index) {
let currentIndex = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve reached the specified node.
while (currentNode) {
if (currentIndex === index) {
// We’re at the node at the given index!
return currentNode.data
}
// We’re not there yet...
currentNode = currentNode.next
currentIndex++
}
// If you’re here, the given index is larger
// than the number of elements in the list.
return null
}
setElementAt(index, value) {
let currentIndex = 0
let currentNode = this.head
// Traverse the list, keeping count of
// the nodes that you visit,
// until you’ve reached the specified node.
while (currentNode) {
if (currentIndex === index) {
// We’re at the node at the given index!
currentNode.data = value
return true
}
// We’re not there yet...
currentNode = currentNode.next
currentIndex++
}
// If you’re here, the given index is larger
// than the number of elements in the list.
return false
}
}
Wait…this “linked list” thing is beginning to look like a Python or JavaScript array, but not as fully-featured. What’s going on here?
The truth about linked lists
Here’s the truth: there’s a better-than-even chance that you’ll never use them…directly.
If you program in most languages from the 1990s or later (for example, Python was first released in 1991, PHP’s from 1994, Java and JavaScript came out in 1995), you’re working with arrays — or in Python’s case, lists, which are almost the same thing — that you can you can add elements to, remove elements from, perform searches on, and do all sorts of things with.
When you use one of these data types in a modern language…
Python lists or a JavaScript arrays
Dictionaries, also known as objects in JavaScript, hashes in Ruby, or associative arrays
Stacks and queues
React components
…there’s a linked list behind the scenes, moving data around by traversing, adding, and deleting nodes. There’s a pretty good chance that you’re indirectly using linked lists in your day-to-day programming; you’re just insulated from the details by layers of abstractions.
So why do they still pose linked list challenges in coding interviews?
History plays a major factor.
In older languages like FORTRAN (1957), Pascal (1970), and C (1972), arrays weren’t dynamic, but fixed in size. If you declared an array with 20 elements, it remained a 20-element array. You couldn’t add or remove elements at run-time.
But Pascal and C supported pointers from the beginning, and pointers make it possible to create dynamic data structures — the kind where you can add or delete elements at run-time. In those early pre-web days, when programming languages’ standard libraries weren’t as rich and complete as today’s, and you often had to “roll your own” dynamic data structures, such as trees, queues, stacks, and…linked lists.
If you majored in computer science in the ’70s, ’80s, and even the ’90s, you were expected to know how to build your own dynamic data structures from scratch, and they most definitely appeared on the exam. These computer science majors ended up in charge at tech companies, and they expected the people they hired to know this stuff as well. Over time, it became tradition, and to this day, you’ll still get the occasional linked list question in a coding interview.
What’s the point in learning about linked lists when we’re mostly insulated from having to work with them directly?
For starters, there’s just plain old pragmatism. As long as they’re still asking linked list questions in coding interviews, it’s a good idea to get comfortable with them and be prepared to answer all manner of questions about algorithms and data structures.
Secondly, it’s a good way to get better at the kind of problem solving that we need in day-to-day programming. Working with linked lists requires us to think about pointers/references, space and time efficiency, tradeoffs, and even writing readable, maintainable code. And of course, there’s always a chance that you might have to implement a linked list yourself, whether because you’re working on an IoT or embedded programming project with a low-level language like C or implementing something lower-level such as the reconciler in React.
Coming up next
Adding a new element to the head of a linked list
Adding a new element at a specific place in the middle of a linked list
StartupBus is no ordinary hackathon. It doesn’t happen in an afternoon in the comfortable surroundings of a coworking space, cafe, or corporate office. It takes THREE DAYS. On a BUS. With all the regular problems posed by a road trip (such as unreliable power and spotty wifi) as well as additional challenges that the organizers have devised. It’s been described as “Navy SEAL training for techies and entrepreneurs.”
While on the bus, the participants — we call them buspreneurs — form teams, come up with an idea for a startup, and build the business and the software that supports it. At the same time, they’re working on a pitch for that business, and practicing the pitch regularly.
After three days when the bus reaches its destination city — Austin, Texas — the real competition begins. StartupBus Florida’s bus will meet up with the other 4 buses coming from different parts of the U.S. and Mexico, and all the teams will pitch in front of judges in the semifinals. A handful of the best teams will go on to the finals, where they’ll pitch to the finals judges. And one will emerge victorious.
StartupBus Florida traditionally departs from Tampa Bay, and we have a solid track record. We had two teams make it to the finals in 2017 and 2019, and our alumni have gone on to start their own companies, build notable careers, and help grow Tampa’s tech scene. This will be the first StartupBus event since 2019, and we’re excited to be back!
StartupBus Florida doesn’t do what it does alone — it’s backed by our favorite hometown heroes: our sponsors! They are…
CoreX Legal, the legal firm built for startups. CoreX know the tech and legal side of all things startup and blockchain.
Hillsborough County’s EDi2, where EDi2 is short for “Economic Development Innovation Initiative.” Edi2 provide grant funding and support for events and opportunities that help Hillsborough County’s entrepreneurs become successful.
Join us at the StartupBus Warm-Up! Come meet StartupBus Florida’s buspreneurs (contestants) and conductors (coaches), sponsors, alumni, and fans at Green Bench Brewing in St. Pete.
Questions you might have about the event
When and where, again? Tuesday, July 19th at 6:30 p.m. at Green Bench Brewing.
When does StartupBus take place? The event starts with a 3-day bus ride that runs from the morning of Wednesday, July 27 to the early evening on Friday, July 29. The final two events happen in the destination city, with the semifinals on Saturday, July 30 and the finals on Sunday, July 31.
Where is the destination city? It’s Austin, Texas.
How many people will be on the bus? It varies from year to year, but typically there are 2 to 3 dozen buspreneurs (participants) on the bus, along with 2 – 4 conductors (coaches).
How many buses will there be? There will be 4 in total. They’ll depart from Cincinnati, Mexico City, Silicon Valley, and Tampa Bay.
I have tech/creative/business skills and want to be a buspreneur. How can I join? Sign up on the StartupBus “Apply” page, select “Florida” and use the code JOEY22.
We’re about a week and a half away from Wednesday, July 27th, when four buses — one from here in Tampa Bay, along with buses from Cincinnati, Silicon Valley, and Mexico City — will start a three-day journey to Austin Texas.
During those three days, the buses’ riders will be participating in a hackathon, where they’ll be challenged to:
Come up with an idea for a startup business
Develop a plan for that startup
Work on a pitch for that startup
Develop the software for that startup
We’ve got a lot of idea, business, and design people on this year’s StartupBus Florida, but we need more developers.
This is a call to developers in the Tampa Bay area and beyond to join StartupBus Florida. You don’t have to be from Tampa Bay or even Florida to ride StartupBus Florida — you just have to be up for a hackathon, road trip, and personal growth all rolled up together!
You don’t have to be an genius-level coder; you just have to know how to code!
I’ve participated in and organized plenty of hackathons, and I’ve seen so many people resist participating because they believe that they’re not good enough coders. I think that if you can code, you’re good enough — and more importantly, participating in a hackathon can make you a better coder!
Here’s the thing: in a hackathon, you’re not coding a full-fledged app in its final form. You’re building a prototype application that demonstrates what would be possible if you had the time and resources to build a full-fledged app in its final form. You’re building the thing that makes the difference between a startup idea and a startup reality.
If you’re unsure about joining StartupBus Florida as a coder, ask yourself these questions:
Can I program a basic web, mobile, or desktop application that can respond to user input?
Can I make that application save data to and retrieve data from a database?
Can I make that application make use of an API?
Can I figure out new things by asking questions and Googling?
If you can answer “yes” to questions 1 and 4, as well as answer “yes” to either questions 2 or 3 (or both), you should join StartupBus Florida as a coder!
Can you code a back end in Express, Flask, or Laravel? You should code on StartupBus Florida.
Can you code a front end in React, Next, Vue, Angular, Svelte or any other framework? You should code on StartupBus Florida.
“Okay, I’m convinced. When does everything take place?”
The bus ride: StartupBus starts with a 3-day bus ride that runs from the morning of Wednesday, July 27 to the early evening on Friday, July 29 when it arrives in Austin, Texas.
The pitch competition: The final two events happen in the destination city, with the semifinals on Saturday, July 30 and the finals on Sunday, July 31.
Travel back home: You’re responsible for your trip home from Austin. I’m flying back on Monday, August 1.
If you’re interviewing for a position that requires you to code, the odds are pretty good that you’ll have to face a coding interview. This series of articles is here to help you gain the necessary knowledge and skills to tackle them!
Over the next couple of articles in this series, I’ll walk you through a classic computer science staple: linked lists. And by the end of these articles, you’ll be able to handle this most clichéd of coding interview problems, satirized in the meme below:
You’ve probably seen the ads for AlgoExpert with the woman pictured above, where she asks you if you want a job at Google and if you know how to reverse a linked list.
But before you learn about reversing linked lists — or doing anything else with them — let’s first answer an important question: what are they?
What are linked lists?
A linked list is a data structure that holds data as a list of items in a specific order. Linked lists are simple and flexible, which is why they’re the basis of many of the data structures that you’ll probably use in your day-to-day programming.
Linked list basics
Nodes
The basic component of a linked list is a node, which is diagrammed below:
In its simplest form, a node is a data structure that holds two pieces of information:
data: This holds the actual data of the list item. For example, if the linked list is a to-do list, the data could be a string representing a task, such as “clean the bathroom.”
next: A linked list is simply a set of nodes that are linked together. In addition to the data it holds, a node should also know where the next node is, and that’s what its next property is for: it points to the next item in the list. In languages like C and Go, this would be a pointer, while in languages like C#, Java, JavaScript, Kotlin, Python, and Swift, this would be a reference.
Here’s a Python implementation of a node. We’ll use it to implement a linked list:
# Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
def __str__(self):
return f"{self.data}"
With Node defined, you can create a new node containing the data “Hello, world!” with this line of code:
new_node = Node("Hello, world!")
To print the data contained inside a node, call Node’sprint() method, which in turn uses the value returned by its __str__() method:
print(new_node)
# Outputs “Hello, world!”
Assembling nodes into a linked list
You create a linked list by connecting nodes together using their next properties. For example, the linked list in the diagram below represents a list of the first four letters of the alphabet: a, b, c, and d, in that order:
The diagram above features the following:
Four nodes, each one for a letter in the list.
A variable called head, which is a pointer or reference to the first item in the list. It’s the entry point to the list, and it’s a necessary part of the list — you can’t access a linked list if you can’t access its head.
An optional variable called tail, which is a pointer or reference to the last item in the list. It’s not absolutely necessary, but it’s convenient if you use the list like a queue, where the last element in the list is also the last item that was added to the list.
Let’s build the linked list pictured above by putting some nodes together:
# Python
# Let’s build this linked list:
# a -> b -> c -> d
head = Node("a")
head.next = Node("b")
head.next.next = Node("c")
head.next.next.next = Node("d")
That’s a lot of nexts. Don’t worry; we’ll come up with a better way of adding items to a linked list soon.
Here’s an implementation that creates the same list but doesn’t rely on chaining nexts:
# Python
# Another way to build this linked list:
# a -> b -> c -> d
head = Node("a")
node_b = Node("b")
head.next = node_b
node_c = Node("c")
node_b.next = node_c
node_d = Node("d")
node_c.next = node_d
To see the contents of the list, you traverse it by visiting each node. This is possible because each node points to the next one in the list:
Of course, the code above becomes impractical if you don’t know how many items are in the list or as the list grows in size.
Fortunately, the repetition in the code — all those prints and nexts — suggests that we can use a loop to get the same result:
# Python
current = head
while current is not None:
print(current)
current = current.next
Here’s the output for the code above:
a
b
c
d
A linked list class
Working only with nodes is a little cumbersome. Let’s put together a linked list class that makes use of the Node class:
# Python
class LinkedList:
def __init__(self):
self.head = None
def __str__(self):
if self.head is None:
return('Empty list.')
result = ""
current_node = self.head
while current_node is not None:
result += f'{current_node}\n'
current_node = current_node.next
return result.strip()
def add_last(self, data):
new_node = Node(data)
# If the list is empty,
# point `head` to the newly-added node
# and exit.
if self.head is None:
self.head = new_node
return
# If the list isn’t empty,
# traverse the list by going to each node’s
# `next` node until there isn’t a `next` node...
current_node = self.head
while current_node.next:
current_node = current_node.next
# If you’re here, `current_node` is
# the last node in the list.
# Point `current_node` at
# the newly-added node.
current_node.next = new_node
This LinkedList class has the following members:
head: A property containing a pointer or reference to the first item in the list, or None if the list is empty.
__init__(): The class initializer, which initializes head to None, meaning that any newly created LinkedList instance is an empty list.
__str__(): Returns a string representation of the contents of the linked list for debugging purposes. If the list contains at least one item, it returns the contents of the list. If the list is empty, it returns the string Empty list.
add_last(): Given a value, it creates a new Node containing that value and adds that Node to the end of the list.
With this class defined, building a new list requires considerably less typing…
# Python
list = LinkedList()
list.add_last("a")
list.add_last("b")
list.add_last("c")
list.add_last("d")
…and displaying its contents is reduced to a single function call, print(list), which produces this output:
a
b
c
d
Coming up next:
JavaScript implementations
Adding an item to the start of a linked list
Finding an item in a linked list
Will you ever use a linked list, and why do they ask linked list questions in coding interviews?
Here’s the list of tech, entrepreneur, and nerd events for Tampa Bay and surrounding areas for the week of Monday, July 18 through Sunday, July 24, 2022.
Every week, with the assistance of a couple of Jupyter Notebooks that I put together, I compile this list for the Tampa Bay tech community.
As far as event types go, this list casts a rather wide net. It includes events that would be of interest to techies, nerds, and entrepreneurs. It includes (but isn’t limited to) events that fall under the category of:
Programming, DevOps, systems administration, and testing
Tech project management / agile processes
Video, board, and role-playing games
Book, philosophy, and discussion clubs
Tech, business, and entrepreneur networking events
Toastmasters (because nerds really need to up their presentation game)
Sci-fi, fantasy, and other genre fandoms
Anything I deem geeky
By “Tampa Bay and surrounding areas”, this list covers events that originate or are aimed at the area within 100 miles of the Port of Tampa. At the very least, that includes the cities of Tampa, St. Petersburg, and Clearwater, but as far north as Ocala, as far south as Fort Myers, and includes Orlando and its surrounding cities.
StartupBus 2022 will depart from Tampa Bay!
If you’re looking for an adventure, a chance to test your startup skills, and an experience that will make your résumé stand out, join me on StartupBus Florida, which departs Tampa Bay on July 27, when it sets course for Austin, Texas!
On this three-day journey, “buspreneurs” will form teams, create a business idea, build a software demo for that idea, and develop pitches for that idea. When they arrive in Austin, they’ll spend two days pitching their startups to a panel of judges.
I was a “buspreneur” on StartupBus Florida in 2019, the last time the event took place, and our team made it to the finals and got the runner-up position. This time, I’m a “conductor” — one of the coaches on the bus — and our team is here to help you rise to the challenge.
If you’d like to get this list in your email inbox every week, enter your email address below. You’ll only be emailed once a week, and the email will contain this list, plus links to any interesting news, upcoming events, and tech articles. Join the Tampa Bay Tech Events list and always be informed of what’s coming up in Tampa Bay!