Welcome to my personal website. I use this space to share some of my thoughts and software that I write in my free time. Sometimes I also publish photos. If you want to get in touch please use LinkedIn or Mastodon.
To merge two lists l1, l2 in python, one can use the following
Create two pointers, p1, p2
Use a while loop, which is terminated, when one of the lists reaches the end
Compare the entries of the list pairwise at the pointer position
If the entries are equal, add l1[p1] to result and increment p1 and p2 by 1
If l1[p1] < l2[p2], then add l1[p1] to result, then increment p1
If l1[p1] > l2[p2], then add l2[p2] to result, then increment p2
Check, which list is not at the end and concat the tail of this list with result
In Python code, this looks the following:
About the author
Friedrich Ewald is an experienced Software Engineer with a Master's degree in Computer Science. He started this website in late 2015, mostly as a digital business card. He is interested in Go, Python, Ruby, SQL- and NoSQL-databases, machine learning and AI and is experienced in building scalable, distributed systems and micro-services at multiple larger and smaller companies.