Cloud computing provides pay-per-use IT services through the Internet. Although cloud computing resources can help scientific workflow applications, several algorithms face the problem of meeting the user's deadline while minimising the cost of workflow execution. In the cloud, selecting the appropriate type and the exact number of VMs is a major challenge for scheduling algorithms, as tasks in workflow applications are distributed very differently. Depending on workflow requirements, algorithms need to decide when to provision or de-provision VMs. Therefore, this paper presents an algorithm for effectively selecting and allocating resources. Based on the workflow structure, it decides the type and number of VMs to use and when to lease and release them. For some structures, our proposed algorithm uses the initial rented VMs to schedule all tasks of the same workflow to minimise data transfer costs. We evaluate the performance of our algorithm by simulating it with synthetic workflows derived from real scientific workflows with different structures. Our algorithm is compared with Dyna and CGA approaches in terms of meeting deadlines and execution costs. The experimental results show that the proposed algorithm met all the deadline factors of each workflow, while the CGA and Dyna algorithms met 25% and 50%, respectively, of all the deadline factors of all workflows. The results also show that the proposed algorithm provides more cost-efficient schedules than CGA and Dyna.