Transforming Recursion to Iteration in Programming

Author(s):  
Athanasios Tsadiras

The main advantage of a Recursive Algorithm (an algorithm defined in terms of itself) is that it can be easily described and easily implemented in a programming language (van Breughel, 1997). On the other hand, the efficiency of such an algorithm is relatively low because for every recursive call not yet terminated, a number of data should be maintained in a stack, causing time delays and requiring higher memory space (Rohl, 1984). Solving the same problem iteratively instead of recursively can improve time and space efficiency. For example, to solve a problem that involves N recursive procedure calls, it will require stack space linear to N. On the contrary, using iteration, the program will need a constant amount of space, independent of the number of iterations. There are programming languages, such as Prolog, that do not possess built-in iterative structures and so recursion should be used instead. Nevertheless, there are ways to write recursive programs that have similar behaviour with that of the corresponding iterative programs.

2002 ◽  
Vol 67 (3) ◽  
pp. 1065-1077
Author(s):  
Raymond D. Gumb

AbstractThe Logic of Partial TermsLPTis a strict negative free logic that provides an economical framework for developing many traditional mathematical theories having partial functions. In these traditional theories, all functions and predicates are strict. For example, if a unary function (predicate) is applied to an undefined argument, the result is undefined (respectively, false). On the other hand, every practical programming language incorporates at least one nonstrict or lazy construct, such as the if-then-else, but nonstrict functions cannot be either primitive or introduced in definitional extensions inLPT. Consequently, lazy programming language constructs do not fit the traditional mathematical mold inherent inLPT. A nonstrict (positive free) logic is required to handle nonstrict functions and predicates.Previously developed nonstrict logics are not fully satisfactory because they are verbose in describing strict functions (which predominate in many programming languages), and some logicians find their semantics philosophically unpalatable. The newly developed Lazy Logic of Partial TermsLLis as concise asLPTin describing strict functions and predicates, and strict and nonstrict functions and predicates can be introduced in definitional extensions of traditional mathematical theories.LLis “built on top of”LPT. and, likeLPT, admits only one domain in the semantics. In the semantics, for the case of a nonstrict unary functionhin an LL theoryT, we have ⊨Th(⊥) =y↔ ∀x(h(x) = y), where ⊥ is a canonical undefined term. Correspondingly, in the axiomatization, the “indifference” (to the value of the argument) axiomh(⊥) =y↔ ∀x(h(x) = y)guarantees a proper fit with the semantics. The price paid forLL's naturalness is that it is tailored for describing a specific area of computer science, program specification and verification, possibly limiting its role in explicating classical mathematical and philosophical subjects.


Author(s):  
AMIR SHAIKHHA ◽  
MOHAMMAD DASHTI ◽  
CHRISTOPH KOCH

AbstractDatabase query engines use pull-based or push-based approaches to avoid the materialization of data across query operators. In this paper, we study these two types of query engines in depth and present the limitations and advantages of each engine. Similarly, the programming languages community has developed loop fusion techniques to remove intermediate collections in the context of collection programming. We draw parallels between databases (DB) and programming language (PL) research by demonstrating the connection between pipelined query engines and loop fusion techniques. Based on this connection, we propose a new type of pull-based engine, inspired by a loop fusion technique, which combines the benefits of both approaches. Then, we experimentally evaluate the various engines, in the context of query compilation, for the first time in a fair environment, eliminating the biasing impact of ancillary optimizations that have traditionally only been used with one of the approaches. We show that for realistic analytical workloads, there is no considerable advantage for either form of pipelined query engine, as opposed to what recent research suggests. Also, by using micro-benchmarks, which demonstrate certain edge cases on which one approach or the other performs better, we show that our proposed engine dominates the existing engines by combining the benefits of both.


2020 ◽  
Author(s):  
Cut Nabilah Damni

AbstrakSoftware komputer atau perangkat lunak komputer merupakan kumpulan instruksi (program atau prosedur) untuk dapat melaksanakan pekerjaan secara otomatis dengan cara mengolah atau memproses kumpulan intruksi (data) yang diberikan. (Yahfizham, 2019 : 19) Sebagian besar dari software komputer dibuat oleh (programmer) dengan menggunakan bahasa pemprograman. Orang yang membuat bahasa pemprograman menuliskan perintah dalam bahasa pemprograman seperti layaknya bahasa yang digunakan oleh orang pada umumnya dalam melakukan perbincangan. Perintah-perintah tersebut dinamakan (source code). Program komputer lainnya dinamakan (compiler) yang digunakan pada (source code) dan kemudian mengubah perintah tersebut kedalam bahasa yang dimengerti oleh komputer lalu hasilnya dinamakan program executable (EXE). Pada dasarnya, komputer selalu memiliki perangkat lunak komputer atau software yang terdiri dari sistem operasi, sistem aplikasi dan bahasa pemograman.AbstractComputer software or computer software is a collection of instructions (programs or procedures) to be able to carry out work automatically by processing or processing the collection of instructions (data) provided. (Yahfizham, 2019: 19) Most of the computer software is made by (programmers) using the programming language. People who make programming languages write commands in the programming language like the language used by people in general in conducting conversation. The commands are called (source code). Other computer programs called (compilers) are used in (source code) and then change the command into a language understood by the computer and the results are called executable programs (EXE). Basically, computers always have computer software or software consisting of operating systems, application systems and programming languages.


2010 ◽  
Vol 39 ◽  
pp. 436-440
Author(s):  
Zhi Ming Qu

In recent years, much research has been devoted to the refinement of IPv6; on the other hand, few have investigated the confusing unification of interrupts and Internet QoS. In this position paper, it demonstrates the emulation of interrupts. In order to overcome this quagmire, a novel system is presented for the intuitive unification of expert systems and massive multiplayer online role-playing games. It is concluded that erasure coding can be verified to make heterogeneous, interposable, and event-driven, which is proved to be applicable.


2021 ◽  
Vol 5 (1) ◽  
Author(s):  
Mark Noone ◽  
Aidan Mooney ◽  
Keith Nolan

This article details the creation of a hybrid computer programming environment combining the power of the text-based Java language with the visual features of the Snap! language. It has been well documented that there exists a gap in the education of computing students in their mid-to-late teenage years, where perhaps visual programming languages are no longer suitable and textual programming languages may involve too steep of a learning curve. There is an increasing need for programming environments that combine the benefits of both languages into one. Snap! is a visual programming language which employs “blocks” to allow users to build programs, similar to the functionality offered by Scratch. One added benefit of Snap! is that it offers the ability to create one’s own blocks and extend the functionality of those blocks to create more complex and powerful programs. This will be utilised to create the Hybrid Java environment. The development of this tool will be detailed in the article, along with the motivation and use cases for it. Initial testing conducted will be discussed including one phase that gathered feedback from a pool of 174 first year Computer Science students. These participants were given instructions to work with the hybrid programming language and evaluate their experience of using it. The analysis of the findings along with future improvements to the language will also be presented.


Author(s):  
Christian Lidström ◽  
Dilian Gurov

AbstractWhen developing complex software and systems, contracts provide a means for controlling the complexity by dividing the responsibilities among the components of the system in a hierarchical fashion. In specific application areas, dedicated contract theories formalise the notion of contract and the operations on contracts in a manner that supports best the development of systems in that area. At the other end, contract meta-theories attempt to provide a systematic view on the various contract theories by axiomatising their desired properties. However, there exists a noticeable gap between the most well-known contract meta-theory of Benveniste et al. [5], which focuses on the design of embedded and cyber-physical systems, and the established way of using contracts when developing general software, following Meyer’s design-by-contract methodology [18]. At the core of this gap appears to be the notion of procedure: while it is a central unit of composition in software development, the meta-theory does not suggest an obvious way of treating procedures as components.In this paper, we provide a first step towards a contract theory that takes procedures as the basic building block, and is at the same time an instantiation of the meta-theory. To this end, we propose an abstract contract theory for sequential programming languages with procedures, based on denotational semantics. We show that, on the one hand, the specification of contracts of procedures in Hoare logic, and their procedure-modular verification, can be cast naturally in the framework of our abstract contract theory. On the other hand, we also show our contract theory to fulfil the axioms of the meta-theory. In this way, we give further evidence for the utility of the meta-theory, and prepare the ground for combining our instantiation with other, already existing instantiations.


Author(s):  
Muhammad Shumail Naveed ◽  
Muhammad Sarim ◽  
Kamran Ahsan

Programming is the core of computer science and due to this momentousness a special care is taken in designing the curriculum of programming courses. A substantial work has been conducted on the definition of programming courses, yet the introductory programming courses are still facing high attrition, low retention and lack of motivation. This paper introduced a tiny pre-programming language called LPL (Learners Programming Language) as a ZPL (Zeroth Programming Language) to illuminate novice students about elementary concepts of introductory programming before introducing the first imperative programming course. The overall objective and design philosophy of LPL is based on a hypothesis that the soft introduction of a simple and paradigm specific textual programming can increase the motivation level of novice students and reduce the congenital complexities and hardness of the first programming course and eventually improve the retention rate and may be fruitful in reducing the dropout/failure level. LPL also generates the equivalent high level programs from user source program and eventually very fruitful in understanding the syntax of introductory programming languages. To overcome the inherent complexities of unusual and rigid syntax of introductory programming languages, the LPL provide elementary programming concepts in the form of algorithmic and plain natural language based computational statements. The initial results obtained after the introduction of LPL are very encouraging in motivating novice students and improving the retention rate.


Sign in / Sign up

Export Citation Format

Share Document